diff --git a/__tests__/bugs/issue-1836-spec.ts b/__tests__/bugs/issue-1836-spec.ts new file mode 100644 index 0000000000..6984e1a10d --- /dev/null +++ b/__tests__/bugs/issue-1836-spec.ts @@ -0,0 +1,30 @@ +import { Gauge } from '../../src'; +import { pick } from '../../src/utils'; +import { createDiv } from '../utils/dom'; + +describe('#1836', () => { + it('gauge animate', () => { + const gauge = new Gauge(createDiv(), { + width: 600, + height: 300, + autoFit: false, + percent: 0.65, + range: { + color: 'l(0) 0:#5d7cef 1:#e35767', + }, + }); + + gauge.render(); + expect(gauge.chart.getOptions().animate).toBe(true); + // 子 view 继承父类 + expect(gauge.chart.views.every((v) => v.getOptions().animate === true)).toBe(true); + + gauge.update({ + ...gauge.options, + animation: false, + }); + expect(gauge.chart.getOptions().animate).toBe(false); + // 子 view 都关闭动画 + expect(gauge.chart.views.every((v) => v.getOptions().animate === false)).toBe(true); + }); +}); diff --git a/src/plots/gauge/adaptor.ts b/src/plots/gauge/adaptor.ts index e7ac60a94c..aabf308e84 100644 --- a/src/plots/gauge/adaptor.ts +++ b/src/plots/gauge/adaptor.ts @@ -128,11 +128,12 @@ function other(params: Params): Params { export function adaptor(params: Params) { // flow 的方式处理所有的配置到 G2 API return flow( + // animation 配置必须在 createView 之前,不然无法让子 View 生效 + animation, geometry, meta, statistic, interaction, - animation, theme, other // ... 其他的 adaptor flow