Skip to content
peakcharts

DonutChart

A pie with the middle cut out, so the labels have room.

Traffic sources
Traffic sourcesClick a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.Organic: 46Direct: 24Referral: 18Paid: 12100Total
Click a mark to pin its value
Organic 46Direct 24Referral 18Paid 12
View data
Traffic sources
LabelValue
Organic46
Direct24
Referral18
Paid12
<DonutChart title="Traffic sources" data={data} />

Usage

DonutChart.tsx
import { DonutChart } from 'peakcharts';
import 'peakcharts/styles.css';

const data = [
  { label: 'Organic', value: 46 },
  { label: 'Direct', value: 24 },
  { label: 'Referral', value: 18 },
  { label: 'Paid', value: 12 },
];

export default function Example() {
  return <DonutChart title="Traffic sources" data={data} />;
}

Data

data takes { label: string; value: number; color?: string }[]. Input arrays are never mutated and order is preserved.

  • Values must be non-negative.
  • Takes colors, or a color on each datum.

Every chart also accepts the common props: description, height, color, variant, animate, formatValue and className.