Pie Chart

About this component

Pie Chart

Recharts pie/donut chart on the shadcn ChartContainer: per-slice colors from config, adjustable donut hole, optional legend, and a name-keyed tooltip. Config-driven colors via --chart tokens.

Usage

The import and the props worth knowing about, in one place.

import { PieChart } from "@/components/beste/component/pie-chart";

<PieChart
  dataKey="value"
  nameKey="segment"
  donut={0.55}
  showLegend
  config={{
    retailers: { label: "Retailers", color: "var(--chart-1)" },
    distributors: { label: "Distributors", color: "var(--chart-2)" },
  }}
  data={[
    { segment: "retailers", value: 2884 },
    { segment: "distributors", value: 1432 },
  ]}
/>

Keyboard and gestures

Every one of these is in the component already. They are listed because a props table cannot mention a gesture, so nothing else on this page can tell you they exist.

Hover a sliceThe tooltip names the segment and its value.

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
data*Array<Record<string, string | number>>—
config*ChartConfig—Config keyed by the nameKey values: { chrome: { label, color } }
dataKey*string—Numeric field that sizes each slice
nameKey*string—Field whose value picks the slice color (--color-{value}) and label
donutnumber—Inner radius as a fraction (0 = full pie, 0.6 = donut)
showLegendboolean—
classNamestring—

More Chart components

View all Chart