-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(change-data): 饼图支持动态更新数据 & 其他若干处理,见 PR 描述 (#2257)
* feat(pie): 饼图支持动态更新数据 & 过滤非法数据,如 NaN * docs(demo): 增加一个动态更新的饼图 demo * test(pie): 添加饼图动态更新数据 & 非法数据 NaN 输入的单测 * refactor(pie): 将饼图 defaultOptions 作为静态方法获取 & 饼图中心文本更新后仍然可以用默认样式 * test(pie): 添加饼图 utils& default-options 单测 * fix: 修改单测问题 * test: 添加带 changedata 的 annotaton 单测 * test: 补充 defaultOptions 的单测 * test(pie): 补充单测
- Loading branch information
Showing
13 changed files
with
415 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Pie } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ type: '分类一', value: 27 }, | ||
{ type: '分类二', value: 25 }, | ||
{ type: '分类三', value: 18 }, | ||
{ type: '分类四', value: 15 }, | ||
{ type: '分类五', value: 10 }, | ||
{ type: '其他', value: 5 }, | ||
]; | ||
|
||
const piePlot = new Pie('container', { | ||
appendPadding: 10, | ||
data, | ||
angleField: 'value', | ||
colorField: 'type', | ||
radius: 0.9, | ||
label: { | ||
type: 'inner', | ||
offset: '-30%', | ||
content: ({ percent }) => `${(percent * 100).toFixed(0)}%`, | ||
style: { | ||
fontSize: 14, | ||
textAlign: 'center', | ||
}, | ||
}, | ||
interactions: [{ type: 'element-active' }], | ||
}); | ||
|
||
piePlot.render(); | ||
setInterval(() => { | ||
piePlot.changeData(data.map((d) => ({ ...d, value: d.value * Math.random() }))); | ||
}, 1200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.