[BLOCKS]/Pie Chart
SYS.UNIT // PIE-CHART

Pie Chart

An interactive pie chart with gesture responder, slice callouts, and smooth animations.

RUNTIME: 0.00 KB
STYLES: StyleSheet
PLATFORMS: iOS • Android • Web

// SYSTEM.STAGE

┌┐
SIM.ACTIVE
Distribution
Interactive breakdown
└┘

Installation

Install the component and its peer dependencies automatically via the CLI:

pnpm dlx @rnblocks/cli add pie-chart

// SYS.USAGE

Drop this code into your screen or view:

pie-chart-example.tsx
1import PieChart from "@/components/pie-chart";
2
3export default function AnalyticsScreen() {
4 const data = [
5 { label: "Category A", value: 40 },
6 { label: "Category B", value: 25 },
7 { label: "Category C", value: 20 },
8 { label: "Category D", value: 15 },
9 ];
10
11 return (
12 <PieChart
13 data={data}
14 theme="dark"
15 variant="brand"
16 size={250}
17 explosionDistance={10}
18 animated={true}
19 title="Distribution"
20 subtitle="Interactive breakdown"
21 onSelectSlice={(slice, index) => {
22 console.log("Selected slice:", slice?.label, "value:", slice?.value);
23 }}
24 />
25 );
26}

// SPEC.PROPS_API

Configurable interfaces for <PieChart />

data
PieDataPoint[]

Array of category data points with label, numerical value, and optional custom slice colors.

DEFAULT:DEFAULT_PIE_DATA
theme
"dark" | "light"

Color theme mode for card surface, borders, and slice palette.

DEFAULT:"dark"
variant
"brand" | "monochrome"

Visual variant: brand emerald/indigo/amber/sky accents, or sleek monochrome slate/zinc shades.

DEFAULT:"brand"
size
number

Diameter in points of the SVG pie chart visualization. Automatically scales down on narrow viewports.

DEFAULT:250
padAngle
number

Angular gap in degrees between adjacent slices (defaults to 0 for a seamless continuous pie).

DEFAULT:0
explosionDistance
number

Distance in pixels by which the active slice explodes outward along its radial bisector.

DEFAULT:10
title
string

Card header title.

DEFAULT:"Distribution"
subtitle
string

Card header context subtitle.

DEFAULT:"Interactive breakdown"
numberFontFamily
string

Custom font family for the header rolling numbers and counters.

DEFAULT:monospace (JetBrains Mono / Menlo)
startAngleOffset
number

Starting rotation offset in degrees (270 = 12 o'clock top).

DEFAULT:270
animated
boolean

Whether to animate slice circular entrance and hover transitions.

DEFAULT:true
loading
boolean

Whether the chart is in a loading state with a circular loading spinner ring.

DEFAULT:false
centerLabel
string

Label displayed in header readout when no slice is selected.

DEFAULT:"Total"
initialIndex
number | null

Optional initial active slice index on mount.

DEFAULT:null
onSelectSlice
(slice: PieDataPoint | null, index: number | null) => void

Callback fired when a slice is clicked, tapped, or hovered.

DEFAULT:undefined

// PERFORMANCE_&_A11Y

Native touch gestures, screen reader attributes, and 60–120 FPS frame budgets:

Chart container declares accessibilityRole='image' with a dynamically generated spoken narrative summarizing total value and category distributions.
Dedicated screen-reader data breakdown list with accessibilityRole='list' announcing every slice label, value, and percentage.
Interactive header readout button announces current slice and supports one-tap reset back to overall Total.
allowFontScaling={false} on fixed-pixel rolling digits and percentage badges to prevent text truncation.
Full keyboard navigation support on web with ArrowLeft, ArrowRight, and Escape.
Mobile PanResponder with non-aggressive gesture claiming and touchAction='pan-y' prevents parent scroll hijacking.