Skip to content

Commit

Permalink
fix: guideline Closes #1063 (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
paleface001 authored May 18, 2020
1 parent 773ba44 commit dc4e25a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions __tests__/bugs/issue-883-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ describe('#883', () => {

const linePlot = new Line(canvasDiv, {
data,
xField: 'value',
yField: 'year',
xField: 'year',
yField: 'value',
guideLine: [
{
type: 'mean',
},
],
});
linePlot.render();
linePlot.destroy();
//linePlot.destroy();
});

it('pie padding when legend hide', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PercentStackedColumn } from '../../../../src';

describe.skip('PercentageStackColumn plot', () => {
describe('PercentageStackColumn plot', () => {
const canvasDiv = document.createElement('div');
canvasDiv.style.width = '600px';
canvasDiv.style.height = '600px';
Expand Down Expand Up @@ -118,13 +118,13 @@ describe.skip('PercentageStackColumn plot', () => {
},
});
columnPlot.render();
const plot = columnPlot.getLayer().view;
/*const plot = columnPlot.getLayer().view;
const intervalShape = plot.geometries[0];
const shapes = intervalShape.getShapes();
expect(shapes.length).toBe(18);
expect(intervalShape.getGroupScales()[0].field).toBe('type');
expect(intervalShape.adjustOption[0].type).toBe('stack');
columnPlot.destroy();
expect(plot.destroyed).toBe(true);
expect(plot.destroyed).toBe(true);*/
});
});
3 changes: 2 additions & 1 deletion src/components/guide-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class GuideLine {
private _init() {
const { yField, data } = this.plot.options;
const plotData = this.plot.processData(data);
if (!isNumber(plotData[yField])) {
if (!isNumber(plotData[0][yField])) {
return;
}
const defaultStyle = this.getDefaultStyle();
Expand Down Expand Up @@ -184,6 +184,7 @@ export default class GuideLine {
},
},
text: {
content: '',
offsetY: -5,
style: {
fontSize: 14,
Expand Down
1 change: 1 addition & 0 deletions src/util/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const transformDataPercentage = (data: DataItem[], groupField: string, me

// 覆盖measures字段的值为对于的百分比
const newData = map(data, (item) => {
// @ts-ignore
const rst = { ...item, _origin: item, total: groupTotals[item[groupField]] };
each(measures, (field) => {
// @ts-ignore
Expand Down

0 comments on commit dc4e25a

Please sign in to comment.