I am using chart.js & chartjs-plugin-datalabels plugin. Right now graph is showing count while hovering the graph and also inside the graph. But I want to show percentage inside the graph instead of count. How can I do that?
My codepen link - https://codepen.io/kaushik-kowboy/pen/BaGxKwy
<!DOCTYPE html>
<html>
<head>
<title>Total Chart - Pie Chart with Labels</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
<style>
#totalChart{
width: 400px !important;
height: 400px !important;
}
</style>
</head>
<body>
<div style="text-align: center;">
<h2>Total Chart - Pie Chart with Labels</h2>
<canvas id="totalChart" width="400" height="400"></canvas>
</div>
<script>
var totalLabels = ["HD","SKY"];
var totalData = ["138","251"];
// Generate Facebook pie chart
var facebookCtx = document.getElementById('totalChart');
new Chart(facebookCtx, {
type: 'pie',
data: {
labels: totalLabels,
datasets: [{
label: 'no of Leads',
data: totalData,
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
},
plugins: [ChartDataLabels],
options: {
}
});
</script>
</body>
</html>```
I have tried to display the percentage amount using ChartDataLabels. but I don't know how to do that. Right now only count is showing.