Skip to content
EspañolEnglish
All components (283)

Sunburst

Data · SunburstChart · .amset-sunburst

What it is and when to use it

A split by levels in rings: the inner one is the categories and each outer ring splits them into subcategories, with the size of their value. To see at a glance where the total comes from and where it weighs most.

When to use it

  • Totals with a hierarchy (sales by country and channel, spending by department and item).
  • nodes are the first-level branches: { key, label, value?, tone?, children? }. A branch is worth the sum of its children, so only the leaves carry value. Children inherit the tone of their branch.
  • Pressing a sector that has children makes it the root, with a breadcrumb to go back.
  • Chart and legend sit side by side when they fit and the legend drops below when not; hovering a legend row marks its arc.

When not to

  • A single layer of parts: DonutChart.
  • Many parts without hierarchy: TreemapChart.
  • Comparing values precisely: BarChart.

Keyboard: Tab goes to the drawing and the arrows move from sector to sector, from the inside out and from branch to branch, with a spoken notice that says the full path.

Accessibility: it is an image (role="img") with a written summary and underneath goes a real table with the path of each part ("Sales › Spain › Web"). When hovering or moving with the arrows, the path and the value are read in a line under the drawing.

Fine-tuning: --amset-sunburst-size is the diameter. Each outer level gets a little lighter to read the depth even if the tone is the same.

What it looks like

Use the arrow keys to move through the values, Home and End to jump to the first and last, and Escape to leave.
Revenue by line
PathValueShare of total
Sales8568%
Sales › Spain6552%
Sales › Spain › Web4032%
Sales › Spain › Store2520%
Sales › France2016%
Services3024%
Services › Support1814.4%
Services › Training129.6%
Others108%

<SunburstChart
  label="Revenue by line"
  nodes={[
    { key: "ventas", label: "Sales", children: [{ key: "es", label: "Spain", value: 65 }, { key: "fr", label: "France", value: 20 }] },
    { key: "otros", label: "Others", value: 10 },
  ]}
/>

Props

Import it with import { SunburstChart } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringWhat is being measured. Required: a chart without a title tells nothing.
nodesrequiredreadonly SunburstNode[]The first-level branches: `{ key, label, value?, tone?, children? }`. A branch is worth the sum of its children.
classNamestringMerged with the library classes; it does not replace them.
errorReactNode—
format(value: number) => string—
loadingboolean—
tableVisibleboolean—

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-sunburst-size22rem

How to change it

.amset-sunburst {
  --amset-sunburst-size: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: