How I can show the percentage value in doughnut chart?
How I can show the percentage value in the doughnut chart?

Think this can help https://chartjs-plugin-datalabels.netlify.app/
How I can show the percentage value in the doughnut chart?
Hi, how do you do this appearance for the chart?
@MaiUbeid w
How I can show the percentage value in the doughnut chart?
Would you be able to share how did you achieve that rounded doughnut it the correct overlap.
I am trying to achieve exactly what you have there. Thanks
join to your question and will be glad if you find the answer and let me know
To show percent values, use npm install chart.js chartjs-plugin-datalabels
import React from "react";
import { Doughnut } from "react-chartjs-2";
import { Chart, ArcElement } from "chart.js";
import ChartDataLabels from "chartjs-plugin-datalabels";
Chart.register(ArcElement, ChartDataLabels);
export default function TestChart() {
const data = {
datasets: [
{
data: [55, 10, 30, 5],
backgroundColor: ["#8D53BB", "#BF7BF5", "#311746", "#5E3280"],
},
],
};
const options = {
plugins: {
datalabels: {
display: true,
color: '#FF0000',
formatter: (value, context) => {
console.log('Test Data Index:', context.dataIndex);
console.log('Test Value:', value);
const staticLabels = [55, 10, 30, 5];
return staticLabels[context.dataIndex];
},
anchor: 'center',
align: 'center',
font: {
weight: 'bold',
size: 16,
},
},
},
};
return <Doughnut data={data} options={options} />;
}