Pie chart component with animated transitions. For the slices drawn as a ring, with room for a total in the center, see the Donut Chart.
A pie chart shows how a whole splits into parts: each slice's angle is its share of the total, so it answers "what fraction is this?" at a glance. It works best when:
Reach for another chart when those don't hold. To compare parts that are close in size, or more than a handful of them, a bar chart puts the values on a common scale. To show how the parts change over time, use a line or area chart. And for the same slices with the total written in the middle, use the donut chart, which takes the same data.
Every slice can be reached from the keyboard, and is announced by its key and value, so a pie chart doesn't depend on seeing its colors (see Accessibility).
A legend names the slices, and lets readers switch them off to compare the rest. Click an item below to hide or show its slice.
Click a legend item to hide or show its slice.
The legend's items and the chart's slices come from the same data, in the same order: a legend item with no colorOverride takes the theme palette's color for its position, just as the slice does. Hiding a slice sets its hide rather than removing it, so it keeps its place — and its color — and the swatches keep matching.
import { Component, computed, signal } from '@angular/core';
import { PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacPieChart, PcacPieChartConfig } from '@pioneer-code/pioneer-charts';
@Component({
imports: [PcacLegend, PcacPieChart],
template: `
<pcac-legend [config]="legend()" (itemClicked)="onItemClicked($event)" />
<pcac-pie-chart [config]="pie()" />
`,
})
export class SnacksComponent {
readonly config = signal<PcacPieChartConfig>({ data: [ ... ], height: 200 });
/** The slices switched off from the legend, by key. */
readonly hidden = signal<ReadonlySet<string>>(new Set());
readonly legend = computed<PcacLegendConfig>(() => ({
heading: 'Snacks',
items: this.config().data.map((slice) => ({
label: String(slice.key),
checked: !this.hidden().has(String(slice.key)),
colorOverride: null,
})),
}));
readonly pie = computed<PcacPieChartConfig>(() => ({
...this.config(),
data: this.config().data.map((slice) => ({ ...slice, hide: this.hidden().has(String(slice.key)) })),
}));
onItemClicked(items: PcacLegendConfigItem[]): void {
this.hidden.set(new Set(items.filter((item) => !item.checked).map((item) => item.label)));
}
}<pcac-pie-chart [config]="config" (sliceClicked)="onClicked($event)" />
import { PcacPieChart, PcacPieChartConfig } from '@pioneer-code/pioneer-charts';| 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. |
| 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. |
| Binding | Description | Payload |
|---|---|---|
| (sliceClicked)="onClicked($event)" | Emitted when a slice is clicked. | PcacData |