Chart.js to change Cursor - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

Chart.js to change Cursor

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Chart.js Legend Customization</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
      <script type="text/javascript" src="https://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script> 
      <link rel="stylesheet" type="text/css" href="https://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js"></script> 
   </head> 
   <body> 
      <div style="width: 100%; height: 100%;"> 
         <canvas id="myChart" style="width: 100%; height: auto;"></canvas> 
      </div> 
      <script type="text/javascript">
var data = {//from   w w  w.  jav  a  2 s.  c om
  labels: [
    "Girls",
    "Boys",
  ],
  datasets: [{
    data: [50, 50],
    backgroundColor: [
      "#FF6283",
      "#36A2EB",
      "#FFCC54"
    ],
    hoverBackgroundColor: [
      "#FF6283",
      "#36A2EB",
      "#FFCC54"
    ]
  }]
};
var ctx = document.getElementById("myChart").getContext("2d");
var myDoughnutChart = new Chart(ctx, {
  type: 'doughnut',
  data: data,
  options: {
    legend: {
      display: true
    },
    hover: {
      onHover: function(e) {
        $("#myChart").css("cursor", e[0] ? "not-allowed" : "default");
      }
    }
  }
});

      </script>  
   </body>
</html>

Related Tutorials