Angular Donut Chart
An Angular donut chart (also called a doughnut or ring chart) built on D3: the slices of a pie drawn as a ring around an empty center, which can hold a short label and subLabel — typically the total the slices add up to. With two slices it's a progress ring. Takes the same data as the Pie Chart, with animated transitions.
Try it
The controls edit the chart's config live; each field is described in the Configuration table.
Donut
Change the settings above and it redraws.
const config: PcacDonutChartConfig = {
data: [...],
innerRadius: 0.6,
label: '2708',
subLabel: 'total',
};When To Use A Donut Chart
A donut chart shows how a whole splits into parts, like a pie chart, and adds one thing: a place for the number the parts add up to. Use it when that number is what readers should see first and the split is the detail — tickets by status around the count of open tickets, a budget by department around the total spend, a storage quota around the space left. It's also the natural shape for a single value out of a whole, like a completion rate, drawn as a ring.
The usual pie chart advice holds: keep it to about five slices or fewer, and switch to a bar chart when the parts are close in size or there are many of them. And if there's nothing worth putting in the middle, the pie chart gives the same slices more room.
One Value As A Ring
Two slices — the part and the rest — with a thin ring and the percentage in the center make a progress or completion ring. Give the remainder a quiet color with colorOverride so the part stands out; the remainder is still a slice, with its own tooltip and click.
Orders shipped on time
const config: PcacDonutChartConfig = {
height: 200,
innerRadius: 0.8,
label: '72%',
subLabel: 'on time',
colorOverride: ['#5ee2a0', 'light-dark(#e5e7eb, #3f3f46)'], // the part, then a quiet remainder
data: [
{ key: 'On time', value: 72, hide: false, data: [] },
{ key: 'Late', value: 28, hide: false, data: [] },
],
};The Center Label
The hole holds up to two lines: label, large, and subLabel, smaller, under it. Each is sized from the hole — the label up to 40px, the sub label up to 16px — and shrunk until it fits across it, so the same config reads well on a small dashboard tile and a full-width page. A line that would have to shrink below 8px to fit is left out rather than drawn illegibly, so keep them short: a number for the label, a word or two for the sub label.
The chart doesn't add up the slices for you, which leaves the label free to be anything — a total, a percentage, a currency amount, a status. To show the total, sum the values when you build the config and format it the way the rest of your page does:
const data: PcacData[] = [ ... ];
const total = data.filter((d) => !d.hide).reduce((sum, d) => sum + Number(d.value ?? 0), 0);
const config: PcacDonutChartConfig = {
data,
label: new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', notation: 'compact' }).format(total),
subLabel: 'total spend',
};Remember to recompute the label when slices are hidden from a legend, if it should only count the slices still shown; the pie chart's legend example works the same way for the donut.
Ring Thickness
innerRadius sets the size of the hole as a fraction of the chart's radius, and with it how thick the ring is. The default, 0.6, balances the two: room for a large label, and slices thick enough to compare. Around 0.75 to 0.85 makes a thin ring that suits a single value or a row of small dashboard charts, where the label is the point. Below about 0.4 the hole gets too small for a label to fit at a readable size, and at 0 there's no hole at all — the chart draws a plain pie.
Label Colors
The center lines use the theme's grays unless labelColor and subLabelColor are set. To recolor every donut in one part of a page — on a dark card, say — set their custom properties in a stylesheet instead; a color in a chart's own config still wins:
.dark-card {
--pcac-donut-center-label-color: #f4f4f5;
--pcac-donut-center-sub-label-color: #a1a1aa;
}Markup
<pcac-donut-chart [config]="config" (sliceClicked)="onClicked($event)" />
API
import { PcacDonutChart, PcacDonutChartConfig } from '@pioneer-code/pioneer-charts';Configuration
| Name | Description |
|---|---|
| data | Collection of PcacData objects. |
| height | Height of chart component. Default is 200px. |
| ariaLabel | What the chart shows, for screen readers — e.g. 'Sales by month, 2026'. The chart is announced as a group with this name, and each bar, slice or point inside it by its own key and value (see Accessibility). When omitted, its type is used: 'Bar chart', 'Pie chart', 'Line chart' and so on. |
| innerRadius | Radius of the hole as a fraction of the chart's radius, from 0 (no hole — a pie) to 0.9; values outside that are clamped. Default 0.6. |
| label | Large text centered in the hole, e.g. a total. Sized to the hole and shrunk to fit across it; left out if it would have to go below 8px. Not drawn when omitted. |
| subLabel | A smaller line under label, fitted the same way. Not drawn when omitted. |
| labelColor / subLabelColor | Any CSS color for the two lines, in place of the theme's $gray-800 and $gray-600. Applied as the --pcac-donut-center-label-color / --pcac-donut-center-sub-label-color custom properties on the chart's .pcac-donut-center group, which a stylesheet can set on an ancestor instead. |
| colorOverride | Slice colors, any CSS color, used in data order instead of the theme palette: the first slice takes the first color. Repeated when there are more slices than colors. Omitted or empty, the theme palette is used. To match a legend, give each of its items the same color with colorOverride. |
Events
| Binding | Description | Payload |
|---|---|---|
| (sliceClicked)="onClicked($event)" | Emitted when a slice is clicked. It emits a copy of the item; set its id to trace it back to your record (see Data Contract). | PcacData |