Vesture

Charts

PieChart

A pie or donut chart with per-slice hover emphasis and a legend that redistributes percentages when a slice is hidden — a standalone chart with no x/y scales, unlike Line/Bar/AreaChart.

PieChartInteractivePieChart

Preview

62%20%10%8%

Usage

tsx
import { InteractivePieChart } from "@vesture/react";

const data = [
  { key: "chrome", label: "Chrome", value: 62 },
  { key: "safari", label: "Safari", value: 20 },
  { key: "firefox", label: "Firefox", value: 10 },
  { key: "edge", label: "Edge", value: 8 },
];

<div style={{ height: 320 }}>
  <InteractivePieChart data={data} innerRadius={0.6} />
</div>

Behavior

  • innerRadius is a fraction of the outer radius (0 = full pie, e.g. 0.6 = a donut with a visible center hole), not a pixel value.
  • Slices with a value of 0 or negative are silently excluded — a zero-width arc has nothing to render.
  • In-slice percentage labels only render on slices with enough angular width to plausibly fit a label; narrow slices suppress their label and stay identifiable via the legend instead. showLabels={false} turns off in-slice labels entirely.
  • InteractivePieChart hovers per-slice (onMouseEnter/Leave on each arc, not a continuous overlay) and nudges the hovered slice outward along its angle bisector.
  • Legend toggle is deliberately different from Line/Bar/AreaChart: hiding a slice recomputes the remaining slices' percentages so they still sum to 100, rather than just removing that arc and leaving the others' percentages stale.

Props

PieChartDataPoint

PropTypeDefaultDescription
keystringRequired. Stable identity for legend/color assignment.
labelstringRequired. Shown in the legend and tooltip.
valuenumberRequired. Zero or negative values are excluded from rendering.
colorstringOverrides the auto-assigned series1-8 token color for just this slice.

PieChart

PropTypeDefaultDescription
dataPieChartDataPoint[]Required.
width / heightnumberRequired.
innerRadiusnumber0Fraction of outerRadius carved out as a center hole — e.g. 0.6 for a donut.
showLabelsbooleantrueTurns off in-slice percentage labels even on slices wide enough to fit one.

InteractivePieChart

PropTypeDefaultDescription
data / innerRadius / showLabelssame as PieChart
heightnumber320Fixed height — width auto-tracks the parent container.