Donut Chart
Ring chart with center space
Preview
Traffic Sources
{ window.Prism.highlightElement($refs.codeEl) }) }"
class="w-full flex items-center justify-between px-6 py-4 text-left bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
View Code
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Traffic Sources</h3>
<canvas id="donutChart"></canvas>
</div>
<script>
new Chart(document.getElementById('donutChart').getContext('2d'), {
type: 'doughnut',
data: {
labels: ['Direct', 'Organic', 'Referral', 'Social'],
datasets: [{ data: [45, 30, 15, 10], backgroundColor: ['rgba(59,130,246,0.8)', 'rgba(16,185,129,0.8)', 'rgba(245,158,11,0.8)', 'rgba(139,92,246,0.8)'] }]
},
options: { responsive: true }
});
</script>