Skip to main content

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​

Storybook

Custom Center​

Storybook

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​

VariantWhat it is
defaultTotal 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​

PropTypeDefaultDescription
data *DonutChartDatum[]—Array<{label, value, color?}>; up to five parts read well
titlestringnoneCaption above the chart and start of the accessible summary
centerValuestring | numberthe totalBig number in the middle
centerLabelstring"Total"Label under the middle number
sizenumber140Largest 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>
KindNameDescription
property / JSON attributedataArray<{label, value, color?}>; up to five parts read well
attributetitleCaption above the chart and start of the accessible summary; default none
property / JSON attributecenter-value / centerValueBig number in the middle; default the total
attributecenter-label / centerLabelLabel under the middle number; default "Total"
attributesizeLargest diameter in px (the ring shrinks with narrow containers); default 140
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus