如何在Amcharts 5中单击传说中的事件?

发布于 2025-01-27 00:08:17 字数 401 浏览 2 评论 0 原文

同样解决的问题在这里 https://www.amcharts.com/docs/v4/tutorials/activate-deactivate-a-pie-a-pie-slice-slice-slice-on-legend-click-click-instead-click-instead-og-toggling/ 我需要具有相同的效果,但在版本5中无效

the same problem solve is here https://www.amcharts.com/docs/v4/tutorials/activate-deactivate-a-pie-slice-on-legend-click-instead-of-toggling/ , I need to have the same effect but it doesnt work in version 5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦初启 2025-02-03 00:08:17

我遇到了同样的问题,这是一个非常琐碎的问题,但是花了一段时间才弄清楚这一点,所以你去了:
您需要做的就是在听众之后设置传奇数据。
正如下面的演示中所述的

在所有事件设置在模板上之后设置Legend数据很重要,否则将不会复制事件

演示:https://www.amcharts.com/demos/highlighting-line-chart-series-on-legend -Hover/

示例

legend.itemContiners.template.events.on("click", function(ev) {
    // Do whatever you want when clicked on Legend
}

legend.data.setAll(chart.series.values)

I had the same problem and it was a really trivial issue, but it took a while to figure this out so here you go:
All you need to do is set the legend data AFTER your listener.
As commented in the demo below

It's is important to set legend data after all the events are set on template, otherwise events won't be copied

Demo: https://www.amcharts.com/demos/highlighting-line-chart-series-on-legend-hover/

Example

legend.itemContiners.template.events.on("click", function(ev) {
    // Do whatever you want when clicked on Legend
}

legend.data.setAll(chart.series.values)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文