I'm using the following code to detect the dataset, but INDEX
is wrong, where the value would be the index of the charts and not the dataset. I need to retrieve the dataset label corresponding to what I clicked on the charts.
function GetChartLabel(events, click, dataset) {
var event = events[0];
if (event) {
var activePoints = event._chart.controller.getElementsAtEvent(click);
var chartData = activePoints[0]._chart.config.data;
var idx = activePoints[0]._index;
var label = chartData.datasets[idx].label;
}
}