Skip to content

Commit

Permalink
feat: chart update (#1739)
Browse files Browse the repository at this point in the history
Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
  • Loading branch information
tangying1027 and xuying.xu authored Feb 23, 2023
1 parent 12b0a52 commit ca29507
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/f2/src/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ class Chart<
}

// props 更新
willReceiveProps(nextProps: IProps) {
willReceiveProps(nextProps: IProps, context) {
const { scale, coord, props: lastProps } = this;
const { style: nextStyle, data: nextData, scale: nextScale } = nextProps;
const { style: lastStyle, data: lastData, scale: lastScale } = lastProps;

// style 更新
if (!isEqual(nextStyle, lastStyle)) {
if (!isEqual(nextStyle, lastStyle) || context !== this.context) {
const style = this.getStyle(nextProps);
coord.updateLayout(style);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/f2/test/components/canvas/canvas.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ describe('Canvas', () => {
expect(rect.getAttribute('fill')).toBe('red');
});

it.skip('chart update', async () => {
it('chart update', async () => {
const chartRef = { current: null };
const context = createContext('基础条形图');
const width = 300;
const height = 300;
const { type, props } = (
<Canvas context={context} pixelRatio={1} animate={false} width={300} height={300}>
<Canvas context={context} pixelRatio={1} animate={false} width={width} height={height}>
<Chart ref={chartRef} data={data} coord={{ transposed: true }}>
<Interval x="genre" y="sold" color="type" />
</Chart>
Expand Down

0 comments on commit ca29507

Please sign in to comment.