Skip to content

Commit bef2c4f

Browse files
authored
fix: pie annotation 默认关闭 text 的动画 (#1810)
* refactor(radar): 雷达图的交互文件夹重命名 & 添加 interactions 测试覆盖率忽略 * fix(issue-1804): 饼图默认将 text annotation 的动画关闭
1 parent ed54d31 commit bef2c4f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

__tests__/unit/plots/pie/index-spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,22 @@ describe('pie', () => {
135135
expect(elements[1].getModel().style?.fill).toBe('blue');
136136
expect(elements[2].getModel().style?.fill).toBe('red');
137137
});
138+
139+
it('pie: annotation animate default to false', () => {
140+
const pie = new Pie(createDiv(), {
141+
width: 400,
142+
height: 300,
143+
data,
144+
angleField: 'value',
145+
colorField: 'type',
146+
});
147+
pie.render();
148+
expect(pie.chart.getTheme().components.annotation.text.animate).toBe(false);
149+
150+
pie.update({ ...pie.options, theme: { color: 'red' } });
151+
expect(pie.chart.getTheme().components.annotation.text.animate).toBe(false);
152+
153+
pie.update({ ...pie.options, theme: { components: { annotation: { text: { animate: true } } } } });
154+
expect(pie.chart.getTheme().components.annotation.text.animate).toBe(true);
155+
});
138156
});

src/plots/pie/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export class Pie extends Plot<PieOptions> {
3838
style: { fontSize: 21, fontWeight: 'bold', fill: '#4D4D4D', textAlign: 'center' },
3939
},
4040
},
41+
/** 默认关闭 text-annotation 动画 */
42+
theme: {
43+
components: {
44+
annotation: {
45+
text: {
46+
animate: false,
47+
},
48+
},
49+
},
50+
},
4151
});
4252
}
4353

0 commit comments

Comments
 (0)