Search code examples
amcharts4

Click Event for Label in Am4charts


Is it possible to add click event for labels as we have for slices in piechart in am4charts? I searched the amcharts docs and couldn't find anything on it.So I was wondering if this can be done?


Solution

  • Yes it's possible - attach an event on the labels' hit event. Assuming you need this on the pie chart slice labels:

    series.labels.template.events.on('hit', function(ev) {
      alert('clicked on ' + ev.target.dataItem.category + ' with a value of ' + ev.target.dataItem.value);
    });