[Chartjs]-Chart.js and Angular โ€“ Click Event on Chart

2๐Ÿ‘

โœ…

Use ()=> instead of function() to keep the scope of this within the callback:

canvas.onclick = (event) => {
    ... code to get the point clicked on such as 
    this.myChart.getPointsAtEvent( event )
};

For more details see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Leave a comment