recharts-pie-chart
evilcharts/recharts-pie-chartFreeComponent
Pie chart component with donut, gradient, and glow effects
Install it
npx shadcn@latest add https://evilcharts.com/r/recharts-pie-chart.jsonSource
1"use client";23import {4 Children,5 createContext,6 isValidElement,7 use,8 useCallback,9 useId,10 useMemo,11 useState,12 type ComponentProps,13 type FC,14 type ReactElement,15 type ReactNode,16} from "react";17import {18 LabelList as RechartsLabelList,19 Pie as RechartsPie,20 PieChart as RechartsPieChart,21 Sector,22 type PieSectorShapeProps,23} from "recharts";24import {25 ChartTooltip,26 ChartTooltipContent,27 type TooltipRoundness,28 type TooltipVariant,29} from "@/registry/ui/recharts-tooltip";30import {31 type ChartConfig,32 ChartContainer,33 getColorsCount,34 LoadingIndicator,35} from "@/registry/ui/recharts-chart";36import { ChartLegend, ChartLegendContent, type ChartLegendVariant } from "@/registry/ui/recharts-legend";37import { ChartBackground, type BackgroundVariant } from "@/registry/ui/recharts-background";38import { motion } from "motion/react";3940// Constants41const LOADING_SECTORS = 5;42const LOADING_ANIMATION_DURATION = 2000; // full loading cycle duration in milliseconds43const DEFAULT_INNER_RADIUS = 0;44const DEFAULT_OUTER_RADIUS = "80%";45const DEFAULT_CORNER_RADIUS = 0;46const DEFAULT_PADDING_ANGLE = 0;47const DEFAULT_START_ANGLE = 0;48const DEFAULT_END_ANGLE = 360;49// Stable empty-array reference so the `glowingSectors` default doesn't change every render50const EMPTY_GLOWING_SECTORS: string[] = [];5152type LabelListProps = ComponentProps<typeof RechartsLabelList>;5354// ─────────────────────────────────────────────────────────────────────────────55// Shared context56// ─────────────────────────────────────────────────────────────────────────────5758/**59 * Shared state for every part of the chart. Lifted into <EvilPieChart /> so that60 * <Pie />, <Tooltip />, <Legend />, and friends can read it without prop drilling.61 * Sub-components are composed freely — the provider is the single source of truth.62 */63type PieChartContextValue = {64 config: ChartConfig; // colors + labels for every sector65 data: Record<string, unknown>[]; // rows rendered by the chart66 dataKey: string; // key holding each sector's numeric value67 nameKey: string; // key holding each sector's name68 isLoading: boolean; // whether the chart shows its loading skeleton69// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from EvilCharts
All 271 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| echarts-area-chartecharts-area-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-bar-chartecharts-bar-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-brushecharts-brush | EvilCharts | Components | Free | 1 dep | |
| echarts-chartecharts-chart | EvilCharts | Components | Free | 1 dep | |
| echarts-composed-chartecharts-composed-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-dotecharts-dot | EvilCharts | Components | Free | 1 dep | |
| echarts-legendecharts-legend | EvilCharts | Components | Free | no deps | |
| echarts-line-chartecharts-line-chart | EvilCharts | Components | Free | 2 deps |
