Sunburst Chart

Pro

The 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.

</>sv-sunburst-chart chartsunbursthierarchyradial
import { SvSunburstChartComponent } from '@styloviz-pro/charts/sunburst-chart';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Zoom kept in the URL

Pro

Deeper rings, stable ids

Pro

Async states

Pro

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 no id, so selection survives a reorder.

Inputs

NameTypeDefaultDescription
loadingbooleanfalseTrue while the hierarchy is being fetched.
errorSvDataError | string | nullnullLoad failure; normalise an `HttpErrorResponse` with `toSvDataError()`.
emptyMessagestring'No data to plot'Copy for the no-data state.
filteredbooleanfalseTrue when the emptiness is caused by a filter rather than an empty set.
nodesreadonly TreemapNode[][]The hierarchy — the treemap's `TreemapNode[]`; a parent without a value, or with `value: 0`, is the sum of its children.
nodeKeySunburstNodeKey(node) => node.labelReads a node's id for `zoomPath` and `nodeSelect`; repeated sibling ids get `~2`, `~3`…
valuePolicySvValuePolicy'omit'What to do with a value that has no angle (negative, NaN, Infinity): `omit` or `reject`.
maxDepthnumber3Rings drawn outward from the current root (1–8).
zoomPathreadonly string[] (two-way)[]Ids from the top of the tree to the zoomed-in root; two-way bindable to persist the view.
sizenumber320Width and height of the square chart in pixels (it scales down to fit).
titlestring''Chart title, shown above the chart and used as the table caption.
showLabelsbooleantrueDraws labels on segments large enough to hold them.
showLegendbooleantrueShows a legend of the first ring under the chart.
ariaLabelstring''Accessible name override; falls back to a generated summary.
customClassstring''Extra CSS classes applied to the root wrapper.
localestringsvLocale()BCP 47 locale for numbers.

Outputs

EventPayload typeDescription
retryvoidThe host should re-run the failed load.
nodeSelectSunburstNodeEventEmitted when a leaf segment is clicked or activated with Enter/Space.
zoomPathChangereadonly 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

Pro

Bound to the names this component actually exposes.

Host class

Pro

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.

Loads giscus.app and GitHub — nothing is fetched until you click.