-1๐
A simple to way to get this done is binding the canvas for onClick event, and use the following code, also here is a working fiddle -> http://jsfiddle.net/Lzo5g01n/4/
document.getElementById("myChart").addEventListener("click", function(e) {
var element = myChart.getElementAtEvent(e)[0];
if (element) {
alert(myChart.config.data.datasets[element._datasetIndex].data[element._index]);
}
});
- [Chartjs]-Chart.js โ Hover labels to display data for all data points on x-axis
- [Chartjs]-Chart.js same Y axis on left and right
Source:stackexchange.com