Chartjs-How to disable click in graph ChartJS

3👍

It seems the onClick property which you set to null doesn’t do anything.

According to the documentation, you can control which events the chart listens to with the events property in the options. For example, if you want the chart to listen to all events, except click, try this:

const myChart = new Chart(this.ctx, {
  type: 'doughnut',
  options: { 
      cutoutPercentage: 85, 
      rotation: 2.72, 
      circumference: 4, 
      aspectRatio: 2.8, 
      legend: { 
          display: false 
      },
      events: ['mousemove', 'mouseout', 'touchstart', 'touchmove'],
  data: {
    labels: ['clients.', 'no clients.'],
    datasets: [{ data: [this.segurosClients, this.prosperaClients], backgroundColor: [gradient, '#E3E7F3'], borderWidth: 1 }],
  },
});

Leave a comment