Manual SVG Donut Chart
A donut chart can be built from layered stroked circles using stroke-dasharray to represent each data segment's proportional size.
Drop your image here
Supports PNG, JPG, BMP, WEBP up to 5MB
Building Segments with Stacked stroke-dasharray Circles
Each data segment in a manual donut chart is represented by its own circle element sharing the same center and radius, with stroke-dasharray set to show only that segment's proportional arc length and stroke-dashoffset rotated to position each segment consecutively around the ring, building up the full donut chart from multiple overlaid circles.
- Each data segment gets its own circle sharing the same center and radius
- stroke-dasharray length is proportional to that segment's data value
- stroke-dashoffset positions each segment consecutively around the full ring
When a Manual Approach Makes Sense Versus a Library
Building a donut chart manually in raw SVG works well for a simple, lightweight dashboard widget with only a few data segments and no need for complex interactivity like tooltips or legends, while a dedicated charting library remains the better choice for more complex dashboards needing many chart types, animations, and built-in accessibility features.
- Manual SVG suits simple, lightweight widgets with few data segments
- Charting libraries suit complex dashboards needing many chart types and features
- Manual approach avoids a library dependency for genuinely simple use cases
Frequently Asked Questions
How do I calculate the dasharray length for each donut chart segment?
Each segment's dash length equals its data percentage multiplied by the circle's full circumference, with the remaining dasharray value set to the full circumference so only that proportional arc is visible.
Can I add hover tooltips to a manually built SVG donut chart segment?
Yes, standard mouseenter/mouseleave event listeners can be attached to each circle segment to show a tooltip with that segment's specific data value on hover.
Related guides
Ready to Convert Your Image to SVG?
Free online converter — no sign-up, no watermarks, results in under 3 seconds.
Try It Free — Convert Image to SVG