Chartjs-Labels for Nested Doughtnut Chart React ChartJS

0👍

For those facing similar issue, to name individual doughnut chart based on separate data within the dataset, I updated the callbacks for the tooltip like so:

plugins: {
      tooltip: {
        enabled: true,
        callbacks: {
          label: (tooltipItem) => {
            var dataIndex = tooltipItem.dataIndex;
            return (tooltipItem.dataset.labels[dataIndex] + ": " + tooltipItem.dataset.data[dataIndex]
            );
          }
        }
      }
   }

Note: For Chart.js 3, "context" parameter can also be used instead of tooltipItem.

Leave a comment