Chartjs-How to create chart with clickable bar using chart.js?

0👍

I think you could add onClick option in the chart options.

The option accepts a function as value.

Here is the doc: https://www.chartjs.org/docs/2.9.4/general/interactions/events.html

  options: {
    onClick(event, clickedElemeents) {
      .... your logic
    },
    legend: {display: false},
    scales: {
      xAxes: [{ticks: {min: 40, max:160}}],
      yAxes: [{ticks: {min: 6, max:16}}],
    }
  }

Leave a comment