-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
angleField 对应的数据为number类型或为空时,正常显示,其他进行筛选过滤,从而避免触发 out of memory
- Loading branch information
Showing
2 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Pie } from '../../src'; | ||
import { createDiv } from '.././utils/dom'; | ||
import { delay } from '.././utils/delay'; | ||
|
||
describe('donut plot', () => { | ||
test('angleField & colorField 配置交换, 不会触发 out-of-memory, 但是坐标为 NaN', () => { | ||
const data = [ | ||
{ | ||
type: '分类一', | ||
value: 27, | ||
}, | ||
{ | ||
type: '分类二', | ||
value: 25, | ||
}, | ||
{ | ||
type: '分类三', | ||
value: 18, | ||
}, | ||
{ | ||
type: '分类四', | ||
value: 15, | ||
}, | ||
{ | ||
type: '分类五', | ||
value: 10, | ||
}, | ||
{ | ||
type: '其它', | ||
value: 5, | ||
}, | ||
]; | ||
|
||
const donutPlot = new Pie(createDiv(), { | ||
width: 640, | ||
height: 400, | ||
radius: 0.8, | ||
innerRadius: 0.64, | ||
padding: 'auto', | ||
data, | ||
angleField: 'type', | ||
colorField: 'value', | ||
}); | ||
|
||
donutPlot.render(); | ||
|
||
expect(donutPlot).toBeDefined(); | ||
expect(donutPlot.chart.geometries[0].elements.length).toBe(0); | ||
}); | ||
|
||
test('value 数据出现字母或其他不合法情况,不会触发 out-of-memory', () => { | ||
const data = [ | ||
{ | ||
type: '分类一', | ||
value: 27, | ||
}, | ||
{ | ||
type: '分类二', | ||
value: 25, | ||
}, | ||
{ | ||
type: '分类三', | ||
value: 18, | ||
}, | ||
{ | ||
type: '分类四', | ||
value: 15, | ||
}, | ||
{ | ||
type: '分类五', | ||
value: 10, | ||
}, | ||
{ | ||
type: '其它', | ||
value: '11a', | ||
}, | ||
]; | ||
|
||
const piePlot = new Pie(createDiv(), { | ||
width: 640, | ||
height: 400, | ||
radius: 0.8, | ||
padding: 'auto', | ||
data, | ||
angleField: 'value', | ||
colorField: 'type', | ||
}); | ||
|
||
piePlot.render(); | ||
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters