-
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.
Browse files
Browse the repository at this point in the history
* fix(radial-bar): filter illegal data (#2394) * fix(radial-bar): 过滤不合法数据不包含null,单测增加断言
- Loading branch information
1 parent
772155d
commit 0f2bd78
Showing
2 changed files
with
73 additions
and
5 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,43 @@ | ||
import { RadialBar } from '../../src'; | ||
import { createDiv } from '../utils/dom'; | ||
|
||
describe('#2394', () => { | ||
it('filter illegal data', () => { | ||
const data = [ | ||
{ name: 'X6', star: '297a' }, | ||
{ name: 'G', star: NaN }, | ||
{ name: 'G2Plot', star: undefined }, | ||
{ name: 'L7', star: '0' }, | ||
{ name: 'AVA', star: null }, | ||
{ name: 'G6', star: 0 }, | ||
{ name: 'F2', star: 7346 }, | ||
{ name: 'G2', star: 10178 }, | ||
]; | ||
|
||
const radialBar = new RadialBar(createDiv(), { | ||
data, | ||
xField: 'name', | ||
yField: 'star', | ||
// maxAngle: 90, //最大旋转角度, | ||
radius: 0.8, | ||
innerRadius: 0.2, | ||
tooltip: { | ||
formatter: (datum) => { | ||
return { name: 'star数', value: datum.star }; | ||
}, | ||
}, | ||
}); | ||
|
||
radialBar.render(); | ||
|
||
expect(radialBar.chart.geometries[0].elements.length).toBe(4); | ||
expect(radialBar.chart.geometries[0].data.length).toBe(4); | ||
|
||
// null认为是0,不过滤 | ||
expect(radialBar.chart.geometries[0].data[0].star).toBeNull(); | ||
|
||
expect(radialBar.chart.geometries[0].data[1].star).toBe(0); | ||
|
||
radialBar.destroy(); | ||
}); | ||
}); |
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