[Chartjs]-Adding Multiple value in Tooltips in ChartJS charts

1👍

By changing parameter passing through percent_data array from percent_data[tooltipItem.datasetIndex] to percent_data[tooltipItem.index].

tooltips: {
  enabled: true,
  callbacks: {
    label: function(tooltipItem, chart) {
      var datasetLabel = chart.datasets[tooltipItem.datasetIndex].label || '';
      return datasetLabel + ': ₹ ' + chart.datasets[tooltipItem.datasetIndex].data[tooltipItem.index] + ' (' + chart.datasets[tooltipItem.datasetIndex].percent_data[tooltipItem.index] + ')%';
    }
  }
}

Leave a comment