I have multiple charts in a single page and i wanted to add a custom onClick action to the charts. Below code is from chart.js documentation. It shows how to add the action when there is a single chart https://www.chartjs.org/docs/latest/configuration/legend.html#custom-on-click-actions
How do I get access to the chart on which the user clicked to update the single chart when there are multiple charts?
onClick: function(e, legendItem) {
var index = legendItem.datasetIndex;
var ci = this.chart;
var meta = ci.getDatasetMeta(index);
// See controller.isDatasetVisible comment
meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
// We hid a dataset ... rerender the chart
ci.update();
}