Skip to content

Commit

Permalink
fix(#1836): fix gauge animate not work (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored Nov 2, 2020
1 parent f2bef05 commit 8d7b4a9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions __tests__/bugs/issue-1836-spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
3 changes: 2 additions & 1 deletion src/plots/gauge/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ function other(params: Params<GaugeOptions>): Params<GaugeOptions> {
export function adaptor(params: Params<GaugeOptions>) {
// flow 的方式处理所有的配置到 G2 API
return flow(
// animation 配置必须在 createView 之前,不然无法让子 View 生效
animation,
geometry,
meta,
statistic,
interaction,
animation,
theme,
other
// ... 其他的 adaptor flow
Expand Down

0 comments on commit 8d7b4a9

Please sign in to comment.