[Chartjs]-How can I show Bootstrap modal when on click in individual bars in chart.js

7👍

canvas.onclick = function(evt) {
    var points = chart.getBarsAtEvent(evt);
    var value = chart.datasets[0].points.indexOf(points[0]);
    if(value == 5){
      $('#myModal').modal('show');
    } else if(value == 4){
      $('#myModal1').modal('show');
    }


  };

0👍

see this,

Click events on Pie Charts in Chart.js

don’t know much about chart.js but I’m sure this library has some method to do this easily, no need to use jquery.

Leave a comment