-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 修复chart未清除缓存的组件的问题 * feat: 增加单测 * fix: 需要在每次更新 coord 前清理已销毁的组件 --------- Co-authored-by: 兵人 <xuezhiqiang.xzq@antgroup.com> Co-authored-by: zengyue <yezengyue@gmail.com>
- Loading branch information
1 parent
5999a92
commit 9216d2b
Showing
3 changed files
with
93 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
Binary file added
BIN
+8.73 KB
...s__/change-data-with-undefined-test-tsx-chart-chart-切换data为undefined-1-snap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,78 @@ | ||
import { jsx, Canvas, Chart, Axis, Interval, Line, Point, Geometry, Area } from '../../src'; | ||
import { createContext, delay } from '../util'; | ||
const context = createContext(); | ||
|
||
const data = [ | ||
{ type: 'a', genre: 'Sports', sold: 5 }, | ||
{ type: 'a', genre: 'Strategy', sold: 10 }, | ||
{ type: 'a', genre: 'Action', sold: 20 }, | ||
{ type: 'a', genre: 'Shooter', sold: 20 }, | ||
{ type: 'a', genre: 'Other', sold: 40 }, | ||
{ type: 'b', genre: 'Sports', sold: 5 }, | ||
{ type: 'b', genre: 'Strategy', sold: 10 }, | ||
{ type: 'b', genre: 'Action', sold: 20 }, | ||
{ type: 'b', genre: 'Shooter', sold: 20 }, | ||
{ type: 'b', genre: 'Other', sold: 40 }, | ||
]; | ||
|
||
type TRecord = typeof data[0]; | ||
// 切换data时,切换为undefined,再切数据时图表缩小问题 | ||
describe('Chart', () => { | ||
it('Chart 切换data为undefined', async () => { | ||
const { props } = ( | ||
<Canvas context={context} pixelRatio={1}> | ||
<Chart<TRecord> data={data}> | ||
<Axis field="genre" /> | ||
<Axis<TRecord> field="sold" /> | ||
<Interval<TRecord> x="genre" y="sold" color="genre" /> | ||
</Chart> | ||
</Canvas> | ||
); | ||
|
||
const canvas = new Canvas(props); | ||
await canvas.render(); | ||
|
||
canvas.update( | ||
( | ||
<Canvas context={context} pixelRatio={1} animate={false}> | ||
<Chart data={undefined}> | ||
<Axis field="genre" /> | ||
<Axis field="sold" /> | ||
<Interval x="genre" y="sold" color="genre" /> | ||
</Chart> | ||
</Canvas> | ||
).props | ||
); | ||
|
||
await delay(100); | ||
|
||
canvas.update( | ||
( | ||
<Canvas context={context} pixelRatio={1} animate={false}> | ||
<Chart data={data}> | ||
<Axis field="genre" /> | ||
<Axis field="sold" /> | ||
<Interval x="genre" y="sold" color="genre" /> | ||
</Chart> | ||
</Canvas> | ||
).props | ||
); | ||
|
||
await delay(100); | ||
|
||
canvas.update( | ||
( | ||
<Canvas context={context} pixelRatio={1} animate={false}> | ||
<Chart data={data.slice(0, 5)}> | ||
<Axis field="genre" /> | ||
<Axis field="sold" /> | ||
<Interval x="genre" y="sold" color="genre" /> | ||
</Chart> | ||
</Canvas> | ||
).props | ||
); | ||
await delay(100); | ||
|
||
expect(context).toMatchImageSnapshot(); | ||
}); | ||
}); |