Chartjs-Getting x,y values from chart click event

0👍

Looking at the Angular2 Chart demos I have discerned the following:

e is a container for a) the chart elements being clicked and b) the mouseevent of the click.

e = {
  active: chartData[],
  event: MouseEvent
}

So since it appears to be a regular old MouseEvent you should be able to do the following to get the position on the chart:

var x:number = e.event.layerX;
var y:number = e.event.layerY;

I recommend double checking this and telling me if I am wrong however.

Leave a comment