Chartjs-Show the values of each arc on doughtnut chart of chart.js

1👍

You can make use of the chart.js datalabels plugin, vor V3 they currently have a release candidate, there is 1 issue thats needs to be resolved before it can be released officially according to this issue of them: https://github.com/chartjs/chartjs-plugin-datalabels/discussions/213

V3 example:

Chart.register(ChartDataLabels)
var options = {
  type: 'pie',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
        label: '# of Votes',
        data: [12, 19, 3, 5, 2, 3],
        borderWidth: 1
      },
      {
        label: '# of Points',
        data: [7, 11, 5, 8, 3, 7],
        borderWidth: 1
      }
    ]
  },
  options: {}
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
  <canvas id="chartJSContainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.1/chart.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0-rc/dist/chartjs-plugin-datalabels.min.js"></script>

</body>

Leave a comment