1
votes

multipal series amcharts assign the id for series but at event fire trying catch the series id but its shows undefined

https://www.amcharts.com/docs/v4/tutorials/toggling-multiple-series-with-a-single-legend-item/

*var series = chart.series.push(new am4charts.ColumnSeries());
series.dataFields.valueY = "value";
series.dataFields.categoryX = "category";
series.id='101'
series.dataItem.setProperty("Id",101);
series.columns.template.propertyFields.fill = "color";
series.columns.template.propertyFields.stroke = "color";

series.columns.template.events.on("hit", function(ev) {
  alert("Clicked on " + ev.target.dataItem.categoryX + ": " + ev.target.dataItem.valueY+":"+ev.target.dataItem.dataContext.id);
});*

Clicked on Distribution: 1500:undefined

1
Not sure what you're trying to do here. What does the link which has Line Series have to do with Columns? Usually an object has a component property which is a reference to the series it belongs to. I would try ev.target.component or ev.target.dataItem.component to see if it's a reference to the columns' series. If it is, then you should be able to just find .id from it. - notacouch

1 Answers

-1
votes

try this
columnSeries.columns.template.events.on("hit", function(ev) { alert("Clicked on " + ev.target.dataItem.categoryX + ": " + ev.target.dataItem.valueY+":"+series.id); });