Sets the click event handler for the legend, which is triggered when the user clicks on a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below.
var chart = new CanvasJS.Chart("container", { . . legend: { itemclick: function(e){ alert( "Legend item clicked with type : " + e.dataSeries.type); } }, . . }); chart.render();
e:{ x, y, chart, dataPoint, dataSeries, dataPointIndex, dataSeriesIndex }
Also See:
5 Comments
Pingback: CanvasJS Version 1.4 Beta with StripLines, Legend Events & Empty Data Points in Chart | CanvasJS
Is there any way of clicking on one of the data points and re-directing to another link? Basically making each point on the graph a link. Please let me know if there is a way to do that.
hardik,
Please refer this example.
How to make each legend item point to a link when clicked on it
Thank you
That means OnClick of legend item it should redirect to a link
Thank you