Conic Gradient Pie Chart Pure CSS
Render a pie chart using only CSS conic gradient with multiple segments and a transparent center for a donut effect.
Code
.pie-chart {
width: 200px;
height: 200px;
border-radius: 50%;
background: conic-gradient(
#e74c3c 0% 25%,
#f39c12 25% 50%,
#2ecc71 50% 75%,
#3498db 75% 100%
);
}
.donut-chart {
width: 200px;
height: 200px;
border-radius: 50%;
background: conic-gradient(
#e74c3c 0% 30%,
#f39c12 30% 55%,
#2ecc71 55% 80%,
#3498db 80% 100%
);
mask: radial-gradient(circle, transparent 60px, black 61px);
-webkit-mask: radial-gradient(circle, transparent 60px, black 61px);
}Report a problem with this exampleOpens a pre-filled issue on GitHub.