Skip to content
peakcharts

PieChart

Share of a whole, best with three to five slices.

Devices
DevicesClick a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.Desktop: 54Mobile: 33Tablet: 13
Click a mark to pin its value
Desktop 54Mobile 33Tablet 13
View data
Devices
LabelValue
Desktop54
Mobile33
Tablet13
<PieChart title="Devices" data={data} />

Usage

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

const data = [
  { label: 'Desktop', value: 54 },
  { label: 'Mobile', value: 33 },
  { label: 'Tablet', value: 13 },
];

export default function Example() {
  return <PieChart title="Devices" 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.