Skip to content

Pie / Donut Chart

A circular chart for showing proportional data. The donut variant includes a centre label for the total or selected value.

Preview

Pie chart

Direct (30%) Organic (20%) Referral (15%) Social (10%) Other (5%)

Donut with centre label

8,420
Total visits
Direct (40%) Search (25%) Referral (15%) Social (10%)

Props

PropTypeDefaultDescription
data{ label: string; value: number; color?: string }[]--Segment data
donutbooleanfalseRender as donut (thinner ring)
centerLabelstring--Donut centre label
centerValuestring | number--Donut centre value
showLegendbooleantrueShow legend beside chart
sizenumber200Chart diameter in px

Code example

React

tsx
import { PieChart } from '@thepace/lexicon/components';

<PieChart
  donut
  centerValue="8,420"
  centerLabel="Total visits"
  data={[
    { label: 'Direct', value: 3368 },
    { label: 'Search', value: 2105 },
    { label: 'Referral', value: 1263 },
    { label: 'Social', value: 842 },
  ]}
/>

CSS class reference

ClassPurpose
.lex-pie-chartFlex container (chart + legend)
.lex-pie-chart__svgSVG circle canvas
.lex-pie-chart__segmentIndividual arc segment
.lex-pie-chart__wrapperRelative wrapper for centre label
.lex-pie-chart__centerCentre label container
.lex-pie-chart__center-valueLarge centre number
.lex-pie-chart__center-labelMuted centre descriptor

Accessibility

  • Use role="img" with aria-label on the SVG listing all segment names and percentages.
  • Provide a data table alternative for screen readers.
  • Segment hover shows tooltip with exact value.
  • White gaps between segments (via stroke technique) ensure segments are visually distinct.

Guidelines

Do

  • Limit to 4–5 segments — group small values as "Other".
  • Use the donut variant to display a summary metric in the centre.
  • Always include a legend with percentages.

Don't

  • Don't use more than 6 segments — the chart becomes unreadable.
  • Don't use 3D pie effects or exploded segments.
  • Don't use a pie chart when exact comparison matters — use a Bar Chart instead.

Released under the MIT License. A product by the pace.