From b36451ede1dd3bf177d0e5ae0ac60cb8a96ccc1f Mon Sep 17 00:00:00 2001 From: "liufu.lf" Date: Fri, 16 Apr 2021 13:01:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BD=8D=E7=BD=AE=E8=AE=A1=E7=AE=97=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/animate/animation/sector-path-update.ts | 5 +++ tests/bugs/charts-574-spec.ts | 40 +++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/bugs/charts-574-spec.ts diff --git a/src/animate/animation/sector-path-update.ts b/src/animate/animation/sector-path-update.ts index 2046bbbdaa..277c5a0238 100644 --- a/src/animate/animation/sector-path-update.ts +++ b/src/animate/animation/sector-path-update.ts @@ -128,6 +128,11 @@ export function sectorPathUpdate(shape: IShape, animateCfg: GAnimateCfg, cfg: An const center = coordinate.getCenter(); const diffStartAngle = curStartAngle - preStartAngle; const diffEndAngle = curEndAngle - preEndAngle; + // 没有 diff 时直接返回最终 attrs,不需要额外动画 + if (diffStartAngle === 0 && diffEndAngle === 0) { + shape.attr('path', path); + return; + } shape.animate( (ratio) => { diff --git a/tests/bugs/charts-574-spec.ts b/tests/bugs/charts-574-spec.ts new file mode 100644 index 0000000000..8c50127763 --- /dev/null +++ b/tests/bugs/charts-574-spec.ts @@ -0,0 +1,40 @@ +import { Chart } from '../../src'; +import { createDiv } from '../util/dom'; + +describe('574', () => { + it('574', () => { + const data = [ + { type: '一线城市', value: 20 }, + { type: '二线城市', value: 0 }, + { type: '三线城市', value: 10 }, + ]; + const chart = new Chart({ + container: createDiv(), + width: 600, + height: 300, + autoFit: true, + }); + chart.data(data); + + chart.coordinate('theta', { + radius: 0.75, + }); + + chart.interval().adjust('stack').position('value').color('type', ['blue', 'green', 'yellow']); + chart.render(); + console.log(chart.geometries[0].elements[0].shape); + const fn = jest.fn(); + chart.geometries[0].elements[2].shape.animate = fn; + chart.changeData([ + { type: '一线城市', value: 20 }, + { type: '三线城市', value: 10 }, + ]); + expect(fn).not.toBeCalled(); + chart.changeData([ + { type: '一线城市', value: 20 }, + { type: '三线城市', value: 15 }, + ]); + expect(fn).toBeCalled(); + chart.destroy(); + }); +}); From 4593377652f030cf45f95bfe08490b8560c214bc Mon Sep 17 00:00:00 2001 From: "liufu.lf" Date: Fri, 16 Apr 2021 13:52:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=20log=20=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/bugs/charts-574-spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/bugs/charts-574-spec.ts b/tests/bugs/charts-574-spec.ts index 8c50127763..66befb77af 100644 --- a/tests/bugs/charts-574-spec.ts +++ b/tests/bugs/charts-574-spec.ts @@ -22,7 +22,6 @@ describe('574', () => { chart.interval().adjust('stack').position('value').color('type', ['blue', 'green', 'yellow']); chart.render(); - console.log(chart.geometries[0].elements[0].shape); const fn = jest.fn(); chart.geometries[0].elements[2].shape.animate = fn; chart.changeData([