DonutChart
BasicCharts
<co-donut-chart>DonutChart shows how a total splits into up to five parts, with the total in the middle and a value legend.
import { DonutChart } from 'health-components';
Examples
Default Palette
Custom Center
Usage
<DonutChart title="Claims by status" data={[{ label: "Paid", value: 412, color: "var(--co-success)" }]} centerLabel="claims" />
When to use
- Share of a whole: claims by status, payer mix.
When not to use
- Comparing sizes precisely or more than five parts: BarChart.
Variants and states
| Variant | What it is |
|---|---|
| default | Total in the centre, legend with value and percent. |
Accessibility
- role img with all parts in the label; the legend prints every value and percent.
Do and don't
- Do: Claims by status with the words in the legend.
- Don't: Use the danger red for a neutral slice.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data * | DonutChartDatum[] | — | Array<{label, value, color?}>; up to five parts read well |
title | string | none | Caption above the chart and start of the accessible summary |
centerValue | string | number | the total | Big number in the middle |
centerLabel | string | "Total" | Label under the middle number |
size | number | 140 | Largest diameter in px (the ring shrinks with narrow containers) |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-donut-chart>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-donut-chart title="…" center-label="…" [data]="data"></co-donut-chart>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | data | Array<{label, value, color?}>; up to five parts read well |
| attribute | title | Caption above the chart and start of the accessible summary; default none |
| property / JSON attribute | center-value / centerValue | Big number in the middle; default the total |
| attribute | center-label / centerLabel | Label under the middle number; default "Total" |
| attribute | size | Largest diameter in px (the ring shrinks with narrow containers); default 140 |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus |