[Chartjs]-Chart.js library V.2 change Cursor to not allowed

2๐Ÿ‘

โœ…

You will be able to get the active point with getElementAtEvent method.

So the code will be

var helpers = Chart.helpers;
helpers.bindEvents(mainDashboardChart, ["mousemove", "touchstart", "touchmove", "mouseout"], function(evt){
var activeElement = mainDashboardChart.getElementAtEvent(evt);
$('#main').css('cursor',activeElement.length ? 'not-allowed' : 'default'); });

0๐Ÿ‘

You can play with the hover option like this :

hover: {
    onHover: function(e) {
        $("#myChart").css("cursor", e[0] ? "pointer" : "default");
    }
}

Working example on a doughnut chart: https://jsfiddle.net/Tintin37/s9m6mggL/1/

Leave a comment