Pie Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Static, beautifully designed pie charts with donut, gradient, and glow effects
Installation
Usage
The pie chart is composable. <EvilPieChart> is the container; compose the parts you need — <EvilPieChart.Legend>, <EvilPieChart.Tooltip>, <EvilPieChart.Background>, and one <EvilPieChart.Pie> — as children. Each <EvilPieChart.Pie> owns its shape props (innerRadius, paddingAngle, cornerRadius, …), isClickable, and glowingSectors, so one chart can mix any combination.
import { EvilPieChart } from "@/components/evilcharts/charts/recharts-pie-chart";
import { type ChartConfig } from "@/components/evilcharts/ui/recharts-chart";const data = [
{ browser: "chrome", visitors: 275 },
{ browser: "safari", visitors: 200 },
{ browser: "firefox", visitors: 187 },
];
const chartConfig = {
chrome: {
label: "Chrome",
colors: { light: ["#3b82f6"], dark: ["#60a5fa"] },
},
safari: {
label: "Safari",
colors: { light: ["#10b981"], dark: ["#34d399"] },
},
firefox: {
label: "Firefox",
colors: { light: ["#f59e0b"], dark: ["#fbbf24"] },
},
} satisfies ChartConfig;<EvilPieChart data={data} dataKey="visitors" nameKey="browser" config={chartConfig}>
<EvilPieChart.Legend isClickable />
<EvilPieChart.Tooltip />
<EvilPieChart.Pie isClickable innerRadius={60} paddingAngle={4} cornerRadius={8}>
<EvilPieChart.Label />
</EvilPieChart.Pie>
</EvilPieChart>Interactive Selection
Add isClickable to <EvilPieChart.Pie> (and <EvilPieChart.Legend>) to make sectors selectable. Handle changes with the onSelectionChange callback on <EvilPieChart>:
<EvilPieChart
data={data}
dataKey="visitors"
nameKey="browser"
config={chartConfig}
onSelectionChange={(selection) => {
if (selection) {
console.log("Selected:", selection.dataKey, "Value:", selection.value);
} else {
console.log("Deselected");
}
}}
>
<EvilPieChart.Legend isClickable />
<EvilPieChart.Tooltip />
<EvilPieChart.Pie isClickable />
</EvilPieChart>Loading State
Pass isLoading to show a placeholder animation while your data loads.
Examples
Examples with different configurations. Customize innerRadius, paddingAngle, cornerRadius, and more.
Gradient Colors
Donut Chart
Set innerRadius above 0 to create a donut — it cuts the hole in the center.
Padded Sectors
paddingAngle adds space between sectors; cornerRadius rounds their corners. Combine with innerRadius for a modern donut look.
A negative paddingAngle with a high cornerRadius overlaps sectors into petals. Add innerRadius for a flower-shaped donut.
Labels
Enable showLabels to draw a label on each sector. Use labelKey to change the data shown and labelListProps for further customization.
Glowing Sectors
Pass an array of sector names (values from your nameKey field) to glowingSectors to give those sectors a subtle glow.
API Reference
Props are grouped by the part they belong to.
The root container. Owns the data, shared selection state, and loading skeleton; all visuals are composed as its children.
The pie series. Self-contained — it generates its own gradients and glow filters, so any number of pies coexist on a page without style collisions. Compose a <Label /> inside it to draw sector labels.
Per-sector labels composed inside a <Pie />. Renders nothing itself — the parent <Pie /> reads its props and draws the label list over the sectors.
The hover tooltip. Hidden automatically while the chart loads.
The sector legend. When isClickable is set, each entry toggles selection of its sector.
An optional decorative pattern behind the pie. Compose it before the <Pie /> so it sits under the sectors.