Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

DonutChart

Parts of a whole as a donut with a centre summary, or a pie (PieChart); slices are selectable and small ones fold into Other.

Charts@gaudi/design-system/charts/DonutChartView in StorybookSource

Installation

pnpm add github:ahmadassaf/design-system recharts

Import from @gaudi/design-system. Load @gaudi/design-system/global.css once and add transpilePackages: ['@gaudi/design-system'] in Next.js.

import { DonutChart } from '@gaudi/design-system/charts/DonutChart';

Copy an example into your project with the shadcn CLI: npx shadcn@latest add https://design.gaudi.site/r/donut-chart-patterned-slices.json.

Usage

import { DonutChart } from '@gaudi/design-system/charts';
<DonutChart title='Where readers came from' ariaLabel='Sessions by source' data={sources} otherThreshold={0.03} onSelect={(slice) => setSource(slice?.label)} />

Examples

Patterned slices

Storybook

Select a topic, small slices as Other

Storybook

API

26 props

Accessibility

The plot is one tab stop named by ariaLabel. The arrow keys walk the points, Home and End jump to the ends, Enter or Space activates and Escape clears; the active point is drawn and read out politely. Every value is mirrored in a data table, and the SVG is hidden from assistive technology.