When using the Chart.js library, I want to change cursor when hovering the mouse over the doughnut.
I do this :
$("#dc_LoadTime").mouseleave(function(){
$("#dc_LoadTime").css("cursor", "default");
});
$("#dc_LoadTime").mouseenter(function(){
$("#dc_LoadTime").css("cursor", "pointer");
});
With this in html page
<canvas id="dc_LoadTime"></canvas>
But this change cursor when mouse enter or leave canvas not on doughnut chart. I cannot find a way to do this. Does anybody know if this is possible?
Change your mouse cursor natively in Windows 10Step 1: Click on the Search box located in the taskbar. Step 2: Type in "mouse." Step 3: Select Change your mouse settings from the resulting list of options to open the primary mouse settings menu. Step 4: Select Additional mouse options.
The cursor property sets or returns the type of cursor to display for the mouse pointer.
In chartjs 2.0 < 2.5 I use hover in option section of the chart, like this:
options: {
hover: {
onHover: function(e) {
$("#id-of-your-canvas").css("cursor", e[0] ? "pointer" : "default");
}
}
}
...and here is a complete example: https://jsfiddle.net/su5fgb5h/5/
In version 2.5 onhover callback has changed and we need second parameter to change cursor:
options: {
hover: {
onHover: function(e, el) {
$("#id-of-your-canvas").css("cursor", el[0] ? "pointer" : "default");
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With