Skip to content

Pie Chart for Angular

AngularCharts

Accessible SVG pie and donut chart for a single part-to-whole breakdown: slices in data order from 12 o’clock, percentage labels, a legend listing every share, keyboard-reachable slices with tooltips, a generated summary, and a data table fallback.

  • Pie or donutSlices run clockwise from the top, with an optional donut hole and center label.
  • Printed sharesPercentage or value labels on slices large enough to hold them.
  • Keyboard slicesOne tab stop; arrow keys move between slices with a tooltip.
  • Data table fallbackA generated summary and a table of category, value, and percent.
  • Not color aloneTextures, legend order, and labels as non-color cues.

Behavior, design tokens, and limitations are described on the Pie Chart page; this page covers the Angular API.

import { Component } from '@angular/core';
import { AuiPieChart } from '@absoluteui/angular/pie-chart';
import type { PieChartSlice } from '@absoluteui/components/pie-chart';
@Component({
selector: 'app-plans',
imports: [AuiPieChart],
template: `<aui-pie-chart label="Plan mix" [slices]="slices" [donut]="true"></aui-pie-chart>`,
})
export class PlansComponent {
readonly slices: PieChartSlice[] = [{ id: 'free', label: 'Free', value: 62 }, { id: 'pro', label: 'Pro', value: 38 }];
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiPieChart } from '@absoluteui/angular/pie-chart';

Defaults for every instance: provideAbsoluteUIConfig({ components: { pieChart: { ... } } }) (see Configuration).

Class AuiPieChart; template reference #ref="auiPieChart".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
label string Required. Chart title: visible text and the accessible name of the plot (aria-labelledby).
hideLabel boolean false Visually hide the title; it stays the accessible name.
description string Visible description below the title, also referenced by aria-describedby (text only).
summary string Replaces the generated accessible summary (aria-describedby).
valueFormat NumberFormatOptions Number format for values in tooltips, labels, the data table, the summary, and axis ticks (ticks use fixed fraction digits).
formatValue (value: number) => string Custom value text; overrides valueFormat everywhere except axis ticks.
slices readonly PieChartSlice[] Required. Slices: { id, label, value: number | null, color?: 1-8 }. Negative, null, and non-finite values are not plotted; they are listed in the summary and the table.
donut boolean false Render a ring (inner radius 60%).
centerLabel string Donut center text. Default: the formatted total of visible slices; empty string: none. aria-hidden (the summary states the total).
valueLabel string Data table header of the value column. Default: localized “Value”.
theme ChartTheme Look and feel: { palette?: string[] (1-8 CSS colors for slots 1-8); fontFamily?; fontSize? (8-32 px); textColor?; gridLines?: boolean; gridColor?; gridDash? (“4 2” or “none”); axisColor?; lineWidth? (0.5-12 px); markerSize? (1-20 px); cornerRadius?, barRadius?, cellRadius?, sliceRadius?, boxRadius? (0-50 px); swatchRadius? (0-8 px); tooltipRadius?, controlRadius? (0-50 px); lineJoin?: ‘round’ | ‘miter’ | ‘bevel’; areaOpacity? (0-1); gradient?: boolean; valueLabelColor?; tooltip?: { background?, color?, borderColor? }; legendPosition?: ‘top’ | ‘bottom’ | ‘start’ | ‘end’; animation?: boolean | { duration?: number (0-5000 ms) } }. Applied as –aui-chart-* custom properties and classes on the host through the CSSOM (CSP-safe); colors are validated with CSS.supports(‘color’). Animation is opt-in and never runs with prefers-reduced-motion: reduce or [data-aui-animation=‘none’].
renderTooltip ChartTooltipRenderer Custom tooltip content as DOM nodes (never HTML strings). context: { title, rows: { label, value, seriesId }[], column, row, source: “pointer” | “focus” | “sync” }. Return null for the default tooltip. The tooltip stays aria-hidden; the focused mark keeps its accessible label.
syncGroup string Synchronized crosshair: charts with the same group show the crosshair, highlight, and tooltip at the same column (category or x index) when one of them is hovered or focused. Focus never moves between charts. Use charts that share their categories or x values.
legend ChartLegendMode 'auto' auto: legend when there is more than one series (pie charts: always).
dataTable ChartTableMode 'toggle' Data table fallback with the exact data: behind a Show data table button (built on first open), always visible, visually hidden (screen readers only), or none.
tooltip boolean true Tooltip on pointer hover and keyboard focus.
patterns boolean false Dash patterns and texture fills so series never differ by color alone. Off by default (plain colors); always on in forced colors. Turn it on when series are told apart by color alone (grouped or stacked series, multi-slice pies) and no labels carry the distinction (WCAG 1.4.1).
height number '300' Plot height in CSS px (integer 120-2000); the width follows the container.
sliceLabels PieChartSliceLabels 'percent' Text printed on slices large enough to hold it.
locale string 'en-US' Number, date, and message locale.
direction Direction 'ltr' rtl mirrors the category/x axis, the value axis side, and Left/Right arrow keys.
Model Type Change output Description
[(hiddenSeries)] readonly string[] (hiddenSeriesChange) Ids of series (or slices) hidden initially; update() replaces the hidden set.
Output Payload Description
(seriesToggled) PieChartSeriesToggleDetail The user toggled a legend entry (pointer or keyboard). Not emitted for update() or setSeriesVisible(). Re-emits aui-series-toggle.
(pointClicked) ChartPointClickDetail A data mark was activated: pointer click or tap, or Enter / Space on the focused mark. label is the category, x value, or item; value is the formatted value text. Keyboard navigation is unchanged. Re-emits aui-point-click.

Call them through a viewChild query or a template reference.

Method Description
setSeriesVisible(id: string, visible: boolean): void Show or hide a series (slice) programmatically; emits no event.

Pattern: SVG part-to-whole chart as a named, described group (role=“group” with aria-roledescription “pie chart” or “donut chart”) of role=“img” slices with roving focus; legend of toggle buttons with each share; data table fallback with value and percent columns.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Pie Chart: Accessibility and performance.