我想知道如何在 amcharts 4 中获取点击行项目的 X\Y 项目详细信息。
我这里有代码: https://stackblitz.com/edit/angular-playground-3qpqlq
series2.segments.template.events.on("hit", (ev) => {
alert('line clicked');//this gets triggered
//but how to i get the line item details here, like X axis and Y axis
//value of the clicked point of the line?
}, this);
最佳答案
LineSeries 数据项不像列那样直接从 hit
事件中获取。您必须查看事件的 target.dataItem.component.tooltipDataItem.dataContext
对象才能获得单击的项目符号的信息:
series2.segments.template.interactionsEnabled = true;
series2.segments.template.events.on(
"hit",
ev => {
var item = ev.target.dataItem.component.tooltipDataItem.dataContext;
alert("line clicked on: " + item.country + ": " + item.marketing);
},
this
);
关于angular - 如何在 amcharts 4 中为 LineSeries 添加 click\hit 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51477177/