I want to change the cursor when the mouse moves on the chart, something like this fiddle.
This works with chart.js v2.4
but not works with v2.6
& v2.7
any idea?
var ctx = document.getElementById("canvas1").getContext("2d");
var mychart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['uno', 'dos', 'tres', 'cuatro'],
datasets: [{
data: [1, 2, 3, 4],
backgroundColor: ["#BDC3C7","#9B59B6","#E74C3C","#26B99A"]
}]
},
options: {
hover: {
onHover: function(e) {
$("#canvas1").css("cursor", e[0] ? "pointer" : "default");
/* without jquery it can be like this:
var el = document.getElementById("canvas1");
el.style.cursor = e[0] ? "pointer" : "default";
*/
}
}
}
});
From
v2.5
onwards parameters of onHover callback has been changed. See PR#3669Previously, activeEvents was the first argument, and event was not passed.
You can check release notes of v2.5
So you've to change your
onHover callback
as follows:updated jsFiddle