[Chartjs]-How to customize percentage label in Doughnutchart ng2 chart.js

1👍

You can convert the values to percentage and then format the data with % and pass it to the chart. Or you can use plugin like this, Example

var options = {
    tooltips: {
        enabled: false
    },
    plugins: {
        datalabels: {
            formatter: (value, ctx) => {
                let sum = 0;
                let dataArr = ctx.chart.data.datasets[0].data;
                dataArr.map(data => {
                    sum += data;
                });
                let percentage = (value*100 / sum).toFixed(2)+"%";
                return percentage;
            },
            color: '#fff',
        }
    }
};

Refer Show Percentile values in DoughnutChart . Happy Coding!!

Leave a comment