CSS sunburst chart — Orbit hierarchical example
A sunburst chart is a pie chart that goes deep. Each ring is a level of hierarchy: the inner ring shows the broadest categories, the next ring breaks each of those into subcategories, and the outer ring drills further. It’s the right chart when your data is genuinely nested — product catalogs, organizational structures, file system breakdowns — and a flat pie would lose all that structure.
This example builds a three-level sunburst showing market share for phone makers, broken down by product line, broken down again by individual model. Each level is its own orbit.
How it works
- Three concentric orbits, three levels of hierarchy.
orbit-2is the inner ring (top-level brands).orbit-4is the middle ring (product lines), andorbit-6is the outer ring (individual models). Each orbit is its own loop of<o-arc>elements. range-Xandfrom-Xconstrain a sub-orbit to a specific arc of the parent. The middle ring usesrange-198because the Apple slice (55%) plus Xiaomi (20%) covers about 198° of the circle — only those subcategories belong on the middle ring. The outer ring usesfrom-138 range-46to drill down only into the iPhone subcategory.flipon a label-bearing<o-arc>flips text upside-down so it remains readable when the arc is on the bottom half of the chart.- Color hierarchy by lightness, not hue. Inner ring uses solid
--o-blue; middle ring uses--o-blue-light; outer ring uses--o-blue-lighter. This visual cue tells the reader “these belong together” without needing a legend.
Customization
Drill into a different brand by changing the from-X and range-X on the outer rings to cover a different arc segment.
Make it interactive by attaching click handlers that re-render the outer rings to drill into the clicked slice:
arc.addEventListener('click', () => { outerRing.style.setProperty('--from', arc.style.getPropertyValue('--start')); outerRing.style.setProperty('--range', arc.style.getPropertyValue('--span'));});Use it for org charts by replacing brands → divisions → teams. The nesting model is identical.
Related
- Donut chart — single-level variant
- Pie chart — solid single-level variant
<o-arc>element reference- Use case: dashboards
Use this in your project
Install Orbit CSS and adapt the data values above to your own hierarchy.