-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(geometry): 修复 element 打标策略导致的数据未被全部绘制的问题。Closed #2141
- Loading branch information
Showing
5 changed files
with
80 additions
and
21 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
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
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
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
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,58 @@ | ||
import { Chart } from '../../src'; | ||
import { createDiv } from '../util/dom'; | ||
|
||
import 'jest-extended'; | ||
|
||
describe('#2141', () => { | ||
const data = [ | ||
{ item: '事例一', count: 40, percent: 0.4 }, | ||
{ item: '事例二', count: 21, percent: 0.21 }, | ||
{ item: '事例三', count: 17, percent: 0.17 }, | ||
{ item: '事例四', count: 13, percent: 0.13 }, | ||
{ item: '事例五', count: 9, percent: 0.09 }, | ||
]; | ||
|
||
const chart = new Chart({ | ||
container: createDiv(), | ||
width: 400, | ||
height: 300, | ||
}); | ||
|
||
chart.coordinate('theta', { | ||
radius: 0.75, | ||
}); | ||
|
||
chart.data(data); | ||
chart.animate(false); | ||
const interval = chart | ||
.interval() | ||
.position('percent') | ||
.adjust('stack') | ||
.style({ | ||
lineWidth: 1, | ||
stroke: '#fff' | ||
}); | ||
chart.render(); | ||
|
||
it('render, id uniq', () => { | ||
// 保证数据同 element 的条数对应 | ||
expect(interval.elements.length).toBe(data.length); | ||
expect(interval.elementsMap).toContainAllKeys(['1', '1-0-1', '1-0-2', '1-0-3', '1-0-4']); | ||
}); | ||
|
||
it('update', () => { | ||
const newData = [ | ||
{ item: '事例一', count: 40, percent: 0.2 }, | ||
{ item: '事例二', count: 21, percent: 0.11 }, | ||
{ item: '事例三', count: 17, percent: 0.27 }, | ||
{ item: '事例四', count: 13, percent: 0.13 }, | ||
{ item: '事例五', count: 9, percent: 0.09 }, | ||
{ item: '事例五', count: 9, percent: 0.1 }, | ||
]; | ||
chart.changeData(newData); | ||
|
||
expect(interval.elements.length).toBe(newData.length); | ||
expect(interval.elements[1].getData()).toEqual({ item: '事例二', count: 21, percent: 0.11 }); | ||
expect(interval.elementsMap).toContainAllKeys(['1', '1-0-1', '1-0-2', '1-0-3', '1-0-4', '1-0-5']); | ||
}); | ||
}); |