Hierarchy · Intermediate

Sunburst

A hierarchy drawn in rings.

Open in playground
Use when
A breakdown of 2 to 3 levels, such as channel > campaign
Avoid when
4 or more levels, or more than 20 leaves

Try it

06

Sunburst

Ad spend share by channel and campaign
SunburstSunburst. 2 levels, innermost ring: Search 48%, PMax 37%, YouTube 15%.SearchBrand 18%Generic 30%PMaxAll products 25%Bestsellers 12%YouTubeRemarketing 9%New users 6%
Sunburst data
Search48 · 48%
Brand · Search18 · 18%
Generic · Search30 · 30%
PMax37 · 37%
All products · PMax25 · 25%
Bestsellers · PMax12 · 12%
YouTube15 · 15%
Remarketing · YouTube9 · 9%
New users · YouTube6 · 6%
A hierarchy in ringsIntermediate

Hover over the chart, or Tab in and use the arrow keys to move between items. The numbers are sample data.

Variants

Named looks for this chart. Each one is the example above with a few options or fields changed. The CLI (ztd-charts example sunburst --variant <id>) and the MCP server know the same names.

No hole

Ad spend share by channel and campaign
Sample data

Wide hole

Ad spend share by channel and campaign
Sample data

Code

SunburstChart.tsx
import { ChartCard, SunburstChart } from "ztd-charts";

const data = [
  {"channel":"Search","campaign":"Brand","spend":18},
  {"channel":"Search","campaign":"Generic","spend":30},
  {"channel":"PMax","campaign":"All products","spend":25},
  {"channel":"PMax","campaign":"Bestsellers","spend":12},
  {"channel":"YouTube","campaign":"Remarketing","spend":9},
  {"channel":"YouTube","campaign":"New users","spend":6},
];

export function Example() {
  return (
    <ChartCard number="06" title="Sunburst" subtitle="Ad spend share by channel and campaign" takeaway="A hierarchy in rings" level="intermediate" replay>
      <SunburstChart
        data={data}
        label="campaign"
        value="spend"
        group="channel"
        highlight="All products"
      />
    </ChartCard>
  );
}

Props

<SunburstChart> takes these props. Rows marked Common work the same on every chart.

28 props

Prop
dataRequiredAn array of objects. Pass CSV, REST or database rows as they areobject[]
labelRequiredLeaf namestring | (d, i) => string
valueRequiredValue fieldstring | (d, i) => number
groupParent group fieldstring | (d, i) => string
pathField list for multi-level pathsstring[]
sortSort largest firstbooleanDefault false
holeCenter hole rationumberDefault 0.3
heightCommonHeight in px. Without it, each chart picks a default that fits its widthnumber
widthCommonFixed width in px. Without it, the chart fits its parentnumber
highlightCommonItem to highlight. An index, a name, an array, or "max" | "min" | "first" | "last" | "none"number | string | (number|string)[] | "max" …
formatCommonValue format. "number" | "integer" | "percent" (values are already percents: 42 → "42%") | "ratio" (0.42 → "42%") | "compact" | "currency" (KRW for Korean locales, otherwise USD; for another currency pass Intl options with currency) | "decimal" or Intl.NumberFormat options"number" | "percent" | "compact" | …
unitCommonUnit appended to values. For example "%" or "ms"string
localeCommonLocale for numbers, dates and the text a chart writes itself (tooltips, screen reader sentences). "ko" or "ko-*" switches to Korean. Falls back to the ThemeProvider localestringDefault "en-US"
animateCommonEntry and update animationbooleanDefault true
durationCommonAnimation length (ms)number
easingCommonMotion curve"spring" | "easeOut" | "easeInOut" | "linear"Default "spring"
staggerCommonDelay between items as they enter (ms)number
reducedMotionCommon"auto" follows the OS setting. true always turns motion offanyDefault "auto"
animateOnViewCommonPlay when the chart scrolls into viewbooleanDefault true
showLabelsCommonLabels drawn on the chart (values and names)booleanDefault true
tooltipCommonShow tooltips. { template: "{label} · {value} · owner {owner}" } writes them: {label}, {value}, {series} or any other column of the row. \n starts a new line, and a line with an empty value is left outtooltipDefault true
syncIdCommonCharts with the same syncId show the hovered x together (line, area, bar, candlestick). <ChartGrid sync> sets one for every chart inside itstring
ariaLabelCommonName for screen readersstring
descriptionCommonDescription for screen readers. Built from the data when omittedstring
onHoverCommonRuns when hover or keyboard focus moves to another item(e: ChartEvent | null) => void
onClickCommonRuns on click, Enter or Space(e: ChartEvent) => void
replayKeyCommonReplays the entry animation when it changesstring | number
themeCommonChanges theme tokens for this chart onlyPartial<ChartTheme>