Do you want to work on this issue?
You can request for a bounty in order to promote it!
在5.x版本实现类似annotation().html,点击图例实时改变环形图中间总数 #6570
houxingx posted onGitHub
问题描述
绘制环形图,中心展示总人数。4.x版本可以使用annotation().html来实现,如下G2 plot源码
chart.annotation().html({
position: ['50%', '100%'],
html: (container, view) => {
const coordinate = view.getCoordinate();
// 弧形的坐标
...
// todo G2 层修复可以返回空字符串 & G2 层修复允许返回非字符串的内容,比如数值 number
return text ? (isString(text) ? text : ${text}
) : '<div></div>';
},
});
现在需要使用G2 5.x版本实现类似功能,已经不支持。
参考了几种方法都不行 1、https://github.com/antvis/G2/discussions/5255
2、直接更新style
mark.style("text",
"100人");
chart.render();
更新后,取消展示的图例又会刷新
3、直接增加事件 interval: click,事件ev中没有找到图例信息
4、直接配置``` legend( { click: function() { ... 在react中形成闭包,处理很麻烦 } })
```
有没有更简洁的办法实现
重现链接
No response
重现步骤
No response
预期行为
No response
平台
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
屏幕截图或视频(可选)
No response
补充说明(可选)
No response