API Reference

Sunburst Chart API

Complete API reference for the Sunburst Chart, including data format, configuration options, custom parts, and context methods.

Data Format

A hierarchical tree structure where each node has a label, value, and optional children. Top-level nodes become the primary branches of the sunburst.

type SunburstChartNode = {
  label: string;
  value: number;
  children: SunburstChartNode[];
};

type SunburstChartData = {
  nodes: SunburstChartNode[];
};
AG Style Config

Sunburst

PropertyTypeDefaultDescription
sunburst.innerRadiusRationumber0.18Inner radius ratio for the center hole (0 to 1).
sunburst.strokeColorstring"white"Color of segment borders.
sunburst.strokeWidthnumber1Width of segment borders.
sunburst.hoverStrokeWidthnumber2Stroke width when a segment is hovered.
sunburst.hoverShadowColorstring"rgba(0,0,0,0.20)"Shadow color on hovered segments.
sunburst.dimOpacitynumber0.32Opacity of non-hovered segments when one is hovered.

Data Label

PropertyTypeDefaultDescription
dataLabel.visiblebooleantrueWhether data labels on segments are visible.
dataLabel.minArcLengthnumber22Minimum arc length in pixels for a label to appear.
dataLabel.minRingWidthnumber18Minimum ring width in pixels for a label to appear.
dataLabel.minFontSizenumber8Minimum font size for data labels.
dataLabel.maxFontSizenumber12Maximum font size for data labels.
dataLabel.colorstring"white"Primary text color for data labels.
dataLabel.secondaryColorstring"rgba(255,255,255,0.82)"Secondary text color for value portion of labels.
dataLabel.fontWeightstring"600"Font weight for data labels.
dataLabel.formatter(args: { label, value, depth, path, branchLabel }) => { label: string; value?: string }Shows label and formatted valueFormatter function for data label content.
Toast Style Config

Sunburst

PropertyTypeDefaultDescription
sunburst.innerRadiusRationumber0.18Inner radius ratio for the center hole (0 to 1).
sunburst.strokeColorstring"transparent"Color of segment borders.
sunburst.strokeWidthnumber0Width of segment borders.
sunburst.hoverBorderColorstring"white"Border color when a segment is hovered.
sunburst.hoverBorderWidthnumber4Border width when a segment is hovered.
sunburst.hoverShadowColorstring"rgba(0,0,0,0.30)"Shadow color on hovered segments.
sunburst.dimOpacitynumber1Opacity of non-hovered segments when one is hovered.

Data Label

PropertyTypeDefaultDescription
dataLabel.visiblebooleantrueWhether data labels on segments are visible.
dataLabel.minArcLengthnumber24Minimum arc length in pixels for a label to appear.
dataLabel.minRingWidthnumber20Minimum ring width in pixels for a label to appear.
dataLabel.minFontSizenumber8Minimum font size for data labels.
dataLabel.maxFontSizenumber13Maximum font size for data labels.
dataLabel.colorstring"white"Primary text color for data labels.
dataLabel.secondaryColorstring"rgba(255,255,255,0.86)"Secondary text color for value portion of labels.
dataLabel.fontWeightstring"700"Font weight for data labels.
dataLabel.formatter(args: { label, value, depth, path, branchLabel }) => { label: string; value?: string }Shows label and formatted valueFormatter function for data label content.

Custom Parts

Override any visual element by providing a custom builder function: (args, context) => Widget

PartArgsDescription
layout{ title: Widget; legends: Widget[]; plot: Widget }Top-level layout composing title, legends, and the plot area.
plot{ dataView: Widget; tooltipArea: Widget }The plot area with data view and tooltip.
dataView{ segments: SunburstChartSegment[] }Container for all sunburst segments.
segmentFlatSegment & { dataLabel: Widget; isHovered: boolean }Individual sunburst segment with depth, angles, and path info.
dataLabelFlatSegment & { isHovered: boolean }Data label on a sunburst segment.
legend{ name: string; index: number; isVisible: boolean }Individual legend item.
titleundefinedChart title element.
tooltipHoveredSunburstSegmentTooltip content for a hovered segment.
tooltipArea{ tooltip: Widget | null; hoveredSegment: HoveredSunburstSegment | null }Tooltip positioning area.

Context: SunburstChartContext

Available in every custom builder via the second argument.

NameTypeKindDescription
dataSunburstResolvedDatapropertyCurrent resolved chart data (filtered by hidden branches).
segmentsFlatSegment[]propertyFlattened list of all visible segments with computed angles.
legendsstring[]propertyAll top-level branch labels.
totalValuenumberpropertySum of all visible branch values.
widthnumberpropertyCurrent chart width in pixels.
heightnumberpropertyCurrent chart height in pixels.
hoveredSegmentKeystring | nullpropertyKey of the currently hovered segment.
hoveredSegmentFlatSegment | nullpropertyCurrently hovered segment data.
configTConfigpropertyThe resolved chart configuration object.
isLegendVisible(index)(index: number) => booleanmethodCheck if a top-level branch is visible.
toggleLegend(index)(index: number) => voidmethodToggle visibility of a top-level branch.
hoverSegment(key)(key: string) => voidmethodSet hover state on a segment by key.
unhoverSegment(key?)(key?: string) => voidmethodClear hover on a segment.
unhoverAllSegments()() => voidmethodClear all segment hover state.
isSegmentHovered(key)(key: string) => booleanmethodCheck if a specific segment is hovered.
setSize(width, height)(width: number, height: number) => voidmethodUpdate chart dimensions.

Custom Part Example

import { ToastSunburstChart } from "@/components/flitter/charts/toast-sunburst-chart";

<ToastSunburstChart
  data={data}
  config={{
    sunburst: { innerRadiusRatio: 0.25 },
    dataLabel: { visible: true },
  }}
/>