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 },
  ]}
/>

Playground

Turn the props on the right; the snippet under them is what you would write to get what you see.

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

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

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*ChartConfigConfig keyed by the nameKey values: { chrome: { label, color } }
dataKey*stringNumeric field that sizes each slice
nameKey*stringField whose value picks the slice color (--color-{value}) and label
donutnumberInner radius as a fraction (0 = full pie, 0.6 = donut)
showLegendboolean
classNamestring

More Chart components

View all Chart

Line Chart

Recharts line chart on the shadcn ChartContainer: multi-series lines with configurable curve, optional dots, active-dot hover, grid, y-axis, legend, and a theme-aware tooltip. Config-driven colors via --chart tokens.

Bar Chart

Recharts bar chart on the shadcn ChartContainer: grouped or stacked multi-series bars with rounded corners, optional grid, y-axis, legend, and a dashed-indicator tooltip. Config-driven colors via --chart tokens.

Area Chart

Recharts area chart on the shadcn ChartContainer: multi-series with per-series gradient fills, optional stacking, grid, y-axis, legend, and a theme-aware tooltip. Config-driven colors via --chart tokens.

Radar Chart

Recharts radar chart on the shadcn ChartContainer: multi-series polar areas with a polar grid, angle axis, adjustable fill opacity, optional legend, and a theme-aware tooltip. Config-driven colors via --chart tokens.

Radial Chart

Recharts radial gauge on the shadcn ChartContainer: a single value plotted as a proportional ring with a muted track and a centered percentage plus caption. Ideal for progress, targets, and completion rates.