Skip to content

Commit

Permalink
fix(v2/pie): 修改 cr 建议
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Jul 26, 2020
1 parent abc1121 commit a81e92d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
11 changes: 4 additions & 7 deletions __tests__/bugs/issue-1245-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Pie } from '../../src';
import { createDiv } from '.././utils/dom';
import { delay } from '.././utils/delay';

describe('donut plot', () => {
test('angleField & colorField 配置交换, 不会触发 out-of-memory, 但是坐标为 NaN', () => {
Expand Down Expand Up @@ -90,12 +89,10 @@ describe('donut plot', () => {
expect(piePlot).toBeDefined();
expect(piePlot.chart.geometries[0].elements.length).toBe(data.length - 1);

delay(3000).then(() => {
piePlot.update({
...piePlot.options,
data: data.map((d, idx) => (idx !== 0 ? { ...d, value: null } : d)),
});
expect(piePlot.chart.geometries[0].elements.length).toBe(data.length);
piePlot.update({
...piePlot.options,
data: data.map((d, idx) => (idx !== 0 ? { ...d, value: null } : d)),
});
expect(piePlot.chart.geometries[0].elements.length).toBe(data.length);
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^4.2.3",
"invariant": "^2.2.4",
"jest": "^26.0.1",
"jest-electron": "^0.1.7",
"jest-extended": "^0.11.2",
Expand Down
10 changes: 4 additions & 6 deletions src/plots/pie/adaptor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deepMix, each, filter, get, isFunction, isNil } from '@antv/util';
import invariant from 'invariant';
import { Params } from '../../core/adaptor';
import { tooltip, interaction, animation, theme } from '../../common/adaptor';
import { flow } from '../../utils';
Expand All @@ -15,13 +16,10 @@ function field(params: Params<PieOptions>): Params<PieOptions> {
const { data, angleField, colorField, color } = options;

// 处理不合法的数据
const progressData = filter(data, (d) => typeof d[angleField] === 'number' || isNil(d[angleField]));
if (progressData.length !== data.length) {
// 先打印出来,后面统一界面提示
console.error('数据源存在不合适的数据,请检查');
}
const processData = filter(data, (d) => typeof d[angleField] === 'number' || isNil(d[angleField]));
invariant(processData.length === data.length, 'Please check whether there exists illegal data');

chart.data(progressData);
chart.data(processData);
const geometry = chart.interval().position(`1*${angleField}`).adjust({ type: 'stack' });

if (colorField) {
Expand Down

0 comments on commit a81e92d

Please sign in to comment.