Donut chart with a center slot — pure SVG, zero JS.
Uses ring-shaped arc paths (outer + inner radius). Supports a :center
slot for custom content (metric value, icon, etc.).
Examples
<.donut_chart data={[
%{label: "Completed", value: 70},
%{label: "Pending", value: 20},
%{label: "Failed", value: 10}
]}>
<:center>70%</:center>
</.donut_chart>
<.donut_chart
data={[%{label: "Used", value: 80}, %{label: "Free", value: 20}]}
hole_ratio={0.65}
/>
Summary
Functions
Attributes
data(:list) (required) - List of%{label, value}(and optional:color).colors(:list) - Override default palette. Defaults to[].hole_ratio(:float) - Ratio of inner radius to outer (0.3–0.8). Controls ring thickness. Defaults to0.55.show_legend(:boolean) - Defaults totrue.animate(:boolean) - Defaults totrue.animation_duration(:integer) - Defaults to600.spacing(:integer) - Gap in pixels between slices (0-8). Defaults to0.show_link_labels(:boolean) - Show leader lines from slices to external labels. Defaults tofalse.show_values(:boolean) - Show data values alongside labels in the legend. Defaults tofalse.active_shape(:boolean) - Enable hover expand effect on slices (Recharts activeShape pattern). Defaults tofalse.active_expand(:integer) - Radius expansion in px on hover when active_shape is true. Defaults to6.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.
Slots
center- Content rendered in the donut center (text, value, etc.).