We are using Chart.js 2.1.4 in a project we are working on. When trying to get the point where a line chart was clicked on, the getElementsAtEvent function is returning an empty Array. I understand this is expected behavior if the user clicks arbitrarily on the chart, but it is also occurring even if the user clicks on a datapoint. Here is our onClick event handling:
options: {
onClick: function(evt){
var firstPoint = this.getElementAtEvent(evt);
if (firstPoint) {
console.log(firstPoint);
} else {
console.log('No point returned');
}
},
In the above code, firstPoint is an Array object with no items in it.