Chartjs-How to add tooltip for the inner doughnut

0πŸ‘

βœ…

To future self:

added data1:[] after data[] in the dataset,

 data: [
{% for row in monthlyChart_avg_prev %}
"{{ row[6] }}",
{% endfor %}
],
data1: [
{% for row in monthlyChart_avg_prev %}
"{{ row[8] }}",
{% endfor %}
],

then in toolips:

 tooltips: {
      callbacks: {
        label: function(tooltipItem, data) {
            var tooltipLabel = data.labels[tooltipItem.index];
            var tooltipData  = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
var tooltipData1 = data.datasets[tooltipItem.datasetIndex].data1[tooltipItem.index];
return tooltipLabel + ': Β£' + tooltipData + ', ' + tooltipData1 + '% ';
                    }
                  }
              }

found on chartsjs.org

Leave a comment