
What is a Doughnut Chart ?
A Doughnut Chart is just like a Pie Chart, but with a hole in the center. It shows proportions of data as slices of a ring — useful for comparing parts of a whole (100%).
Key Features:
- Circular like pie chart, but with a center hole
- You can place text or icons in the center (optional)
- Useful for showing relative percentages or breakdowns
Doughnut Chart Example
<canvas id="myDoughnutChart" width="300" height="300"></canvas>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('myDoughnutChart').getContext('2d');
const myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Facebook', 'Instagram', 'Twitter'],
datasets: [{
label: 'Social Media Usage',
data: [50, 30, 20],
backgroundColor: ['#3b5998', '#e1306c', '#1da1f2']
}]
},
options: {
responsive: true,
cutout: '50%', // Controls hole size
}
});
</script>
Comments
Add new comment