From 089f8cd6426289f33efc8a40914ab8f2e8472c7a Mon Sep 17 00:00:00 2001 From: liwenbo Date: Wed, 6 Dec 2023 20:35:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(animate):=20=E4=BF=AE=E5=A4=8D=E9=A5=BC?= =?UTF-8?q?=E5=9B=BE=E5=8A=A8=E7=94=BB=E6=97=A0=E8=A7=92=E5=BA=A6=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E6=97=B6=E5=85=B6=E4=BD=99=E5=B1=9E=E6=80=A7=E6=9C=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/animate/animation/sector-path-update.ts | 2 +- tests/bugs/pie-update-animate-spec.ts | 34 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/pie-update-animate-spec.ts diff --git a/src/animate/animation/sector-path-update.ts b/src/animate/animation/sector-path-update.ts index d40b0b4947..1354704f98 100644 --- a/src/animate/animation/sector-path-update.ts +++ b/src/animate/animation/sector-path-update.ts @@ -131,7 +131,7 @@ export function sectorPathUpdate(shape: IShape, animateCfg: GAnimateCfg, cfg: An const diffEndAngle = curEndAngle - preEndAngle; // 没有 diff 时直接返回最终 attrs,不需要额外动画 if (diffStartAngle === 0 && diffEndAngle === 0) { - shape.attr('path', path); + shape.attr(toAttrs); return; } diff --git a/tests/bugs/pie-update-animate-spec.ts b/tests/bugs/pie-update-animate-spec.ts new file mode 100644 index 0000000000..1479671bf2 --- /dev/null +++ b/tests/bugs/pie-update-animate-spec.ts @@ -0,0 +1,34 @@ +import { Chart } from '../../src'; +import { createDiv } from '../util/dom'; + +describe('pie update animate', () => { + it('pie should update other attribute without angle change', () => { + 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, + }); + + const interval = chart.interval().adjust('stack').position('value').color('type', ['blue', 'green', 'yellow']); + chart.render(); + + const shape = interval.elements[0].shape; + + interval.color('type', ['#ff0000']); + chart.render(true); + expect(shape.attr('fill')).toEqual('#ff0000'); + + chart.destroy(); + }); +});