Chartjs-Chartjs using angular doughnut not returning formatter function to display label and value

0đź‘Ť

From the chartjs-plugin-datalabels documentation, you need to register the plugin globally or locally].

Register globally:

import ChartDataLabels from 'chartjs-plugin-datalabels';

Chart.register(ChartDataLabels);

Or register locally:

import ChartDataLabels from 'chartjs-plugin-datalabels';

const config: ChartConfiguration = {
  type: 'doughnut',
  data: {
    datasets: data,
    labels: ['Red', 'Orange', 'Yellow', 'Green', 'Blue'],
  },
  options: options,
  plugins: [ChartDataLabels] // Register locally
};

Demo @ StackBlitz

Leave a comment