如何在amcharts 4中为LineSeries添加click \ hit事件?

Dee*_*pak 3 amcharts angular

我想知道如何获取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); 
Run Code Online (Sandbox Code Playgroud)

xor*_*ark 8

hit事件中获取LineSeries数据项并不像从列中那样直接。您必须查看事件的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
);
Run Code Online (Sandbox Code Playgroud)

码笔