Sunburst Chart
ProThe treemap’s radial sibling on the same `TreemapNode` data: rings by depth, arc angle by share of the parent, click or Enter to zoom into a branch and a centre button to zoom out. Pure SVG.
import { SvSunburstChartComponent } from '@styloviz-pro/charts/sunburst-chart';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Zoom kept in the URL
Deeper rings, stable ids
Async states
When to use
A hierarchy where the PATH matters as much as the size — cost by team › service › resource, traffic by section › page. Drilling into one branch at a time; the zoom keeps the parent’s context in the centre. For comparing many leaves by area across the whole tree, a Treemap packs them more legibly — both take the same data.
Async states
- loading
- empty
- error
- retry
Item identity & owned state
- Item key
nodeKey— set this when your rows have noid, so selection survives a reorder.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| loading | boolean | false | True while the hierarchy is being fetched. |
| error | SvDataError | string | null | null | Load failure; normalise an `HttpErrorResponse` with `toSvDataError()`. |
| emptyMessage | string | 'No data to plot' | Copy for the no-data state. |
| filtered | boolean | false | True when the emptiness is caused by a filter rather than an empty set. |
| nodes | readonly TreemapNode[] | [] | The hierarchy — the treemap's `TreemapNode[]`; a parent without a value, or with `value: 0`, is the sum of its children. |
| nodeKey | SunburstNodeKey | (node) => node.label | Reads a node's id for `zoomPath` and `nodeSelect`; repeated sibling ids get `~2`, `~3`… |
| valuePolicy | SvValuePolicy | 'omit' | What to do with a value that has no angle (negative, NaN, Infinity): `omit` or `reject`. |
| maxDepth | number | 3 | Rings drawn outward from the current root (1–8). |
| zoomPath | readonly string[] (two-way) | [] | Ids from the top of the tree to the zoomed-in root; two-way bindable to persist the view. |
| size | number | 320 | Width and height of the square chart in pixels (it scales down to fit). |
| title | string | '' | Chart title, shown above the chart and used as the table caption. |
| showLabels | boolean | true | Draws labels on segments large enough to hold them. |
| showLegend | boolean | true | Shows a legend of the first ring under the chart. |
| ariaLabel | string | '' | Accessible name override; falls back to a generated summary. |
| customClass | string | '' | Extra CSS classes applied to the root wrapper. |
| locale | string | svLocale() | BCP 47 locale for numbers. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| retry | void | The host should re-run the failed load. |
| nodeSelect | SunburstNodeEvent | Emitted when a leaf segment is clicked or activated with Enter/Space. |
| zoomPathChange | readonly string[] | Emits the new `zoomPath` whenever it changes — the output half of `[(zoomPath)]`. |
Wire it to your API
This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.
Template
Bound to the names this component actually exposes.
Host class
Drive the three async inputs from your own fetch.
This component does not emit a query, so it renders what you give it. Call `load()` on your own trigger and bind `nodes`, `loading` and `error`. Set `filtered` when a search or filter is active. It is the difference between "you have no orders" and "no orders match this filter" — telling a customer with 4,000 orders the first one reads as a bug. Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.
Full walkthrough: Connecting to a backend.
Customization & theming
A parent sent with `value: 0` (or with no value, in data from JSON) is the sum of its children, the same rule as the treemap. `maxDepth` rings (default 3, 1–8). Colours per node (`color`) or the palette by position; children take a lighter step of their parent’s hue. `showLabels` and `showLegend` (the first ring). `size` sets the square, which scales down to fit. `valuePolicy` — `omit` (default) drops a node whose value cannot be a share and says so under the plot; `reject` refuses the dataset. A zero-value segment has no angle and is counted in the notice.
Best practices
Do: Bind `[(zoomPath)]` and store it, so a reload or a shared link reopens the same branch. A stale tail (a node that is not in the data) is ignored, not an error. Do: Give nodes stable ids through `nodeKey` when labels can repeat or change; the default key is the label. Don't: Show more than three or four rings at once — the outer arcs become slivers. Zooming is how a reader goes deeper. Tip: Keep the arrays in a meaningful order: segments follow input order, so a refresh never shuffles them.
Accessibility
One tab stop with roving focus: Left/Right move around a ring, Down to the first child, Up to the parent, Home/End to the ends; Enter or Space zooms in (or selects a leaf), Escape or Backspace zooms out. A hidden hint describes this to screen readers. Every segment is named “Label: value (share of parent)”; the chart’s name says where it is zoomed to. The data table lists every drawn segment with its full path, value, share of parent and share of total — and the chart a11y module can show it on screen. Zoom animates transform and opacity only, and not at all under reduced motion.
Feedback on Sunburst Chart
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.