Skip to content

Donut chart

Donut uses the same validated segment contract as pie and adds a configurable inner radius.

Choose donut for a small part-to-whole view when the center carries a short total or status.

Add this element to a native Blade view after installing the package. The example includes its data; replace the values with your own.

<native:donut-chart
class="w-full h-80"
:segments="[
['id' => 'web', 'label' => 'Web', 'value' => 68, 'color' => '#ED3F16'],
['id' => 'store', 'label' => 'Store', 'value' => 32, 'color' => '#2563EB'],
]"
:inner-radius-ratio="0.62"
a11y-label="Spending by category"
/>
Donut chart rendered by NativePHP Charts on Android
Android
Donut chart after selecting a segment on Android
Android · Segment selection
Donut chart running on iOS
iOS
Donut chart after selecting a segment on iOS
iOS · Segment selection

Use stable segment IDs to retain selection after value updates. The center is visual context, not a replacement for an accessible label or legend.

Use pie for a fuller mark or adjust inner-radius-ratio to change the ring weight without changing data.

Theme, preset, segment styles, legend, formatting, and per-segment colors share the pie contract.

See the style options reference for supported keys and ranges.

To handle selection, add _select="selectPoint" and define the method shown in Callbacks and interactions.

_select returns the stable segment ID, label, value, localized value, and original index.

Empty segments render empty-label; invalid totals or IDs fail PHP validation; rejected native snapshots render error-label.

Do not rely on center text alone. Supply a11y-label and meaningful segment labels.

Donut requires segments and adds inner-radius-ratio to the common radial API.

If labels become hard to associate, enable the legend or use a bar chart.