Reputation: 3
I am very new to charts.js and I was wondering if it is possible to make bars in bar charts clickable links? I saw that it was possible for doughnut charts. I'd appreciate any help.
Thanks!
Upvotes: 0
Views: 3859
Reputation: 867
I know you required bar chart but I have used in doughnut chart I hope this will help you..
find example here:- https://jsfiddle.net/ha19ozqy/
document.getElementById("myChart").onclick = function(evt){
var activePoints = myChart.getElementsAtEvent(evt);
var firstPoint = activePoints[0];
var label = myChart.data.labels[firstPoint._index];
var value = myChart.data.datasets[firstPoint._datasetIndex].data[firstPoint._index];
if (firstPoint !== undefined)
alert(label + ": " + value);
};
Upvotes: 2