Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#1836): fix gauge animate not work #1838

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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