Sunburst chart for hierarchical data — pure SVG, zero JS.
Renders concentric rings where each arc represents a node in the hierarchy. The angular span of each arc is proportional to its value. Children occupy the same angular range as their parent but in the next outer ring.
Examples
<.sunburst_chart data={[
%{label: "A", value: 40, children: [
%{label: "A1", value: 25, children: []},
%{label: "A2", value: 15, children: []}
]},
%{label: "B", value: 30, children: [
%{label: "B1", value: 30, children: []}
]},
%{label: "C", value: 30, children: []}
]} />
<.sunburst_chart
data={hierarchy}
ring_width={25}
inner_radius={50}
colors={["oklch(0.60 0.20 240)", "oklch(0.70 0.18 145)", "oklch(0.65 0.22 30)"]}
/>
Summary
Functions
Attributes
data(:list) - Hierarchical data:[%{label, value, children: [...]}]. Defaults to[].colors(:list) - Override default palette. CSS color strings. Defaults to[].ring_width(:integer) - Width of each concentric ring in pixels. Defaults to30.inner_radius(:integer) - Radius of the innermost ring. Defaults to40.show_grid(:boolean) - Unused (included for API consistency). Defaults tofalse.show_labels(:boolean) - Show labels on arcs with sufficient angular span. Defaults totrue.animate(:boolean) - Enable entrance animations. Defaults totrue.animation_duration(:integer) - Animation duration in ms. Defaults to600.theme(:map) - Chart theme overrides (see ChartTheme). Defaults to%{}.id(:string) - Unique ID for the chart (auto-generated if not provided). Defaults tonil.title(:string) - Chart title rendered above the visualization. Defaults tonil.description(:string) - Chart description for context (rendered below title). Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted.