onLegendClick

fires after a click on a legend item

void onLegendClick(Event event,number series,HTMLElement node){ ... };

Parameters

eventEventthe mouse click event
seriesnumberthe ID of the data item or the index of the series in case there are several series in a chart
nodeHTMLElementthe HTML node of the legend item

Example

$$("chartWithSeries").attachEvent("onLegendClick",function(ev,series,node){
    const series = this.config.series[series];
});

Details

For charts with series the second parameter of the event is the index of the series that corresponds to the legend item. For charts without series, e.g. pie and donut charts, the second parameter is the ID of the corresponding data item.

$$("pieChart").attachEvent("onLegendClick", function(event, id, node){
    const item = this.getItem(id);
});
Back to top