Hi, I am looking to make my chart a little more interactive and I would like to get a point
‘s index (of its dataset
) with the following code:
canvas.onclick = function(e) {
const points = chart.getPointsAtEvent(e);
// something like `point.getIndex()` would be great so that I know where this point is in the original dataset
};
Anybody have a good solution for this?
@tyrex1975 It’s not working for me, an error
Uncaught TypeError: Cannot read property 'currentDevicePixelRatio' of undefined
not leaving me alone.I made a workaround to get data from the clicked point;
As we know, the hover event fires before the event click, so I suggest the following solution