Components
Composable chart primitives built on Recharts with theme-aware colors, tooltips, and legends.
Loading preview...
"use client"
import { Pie, PieChart } from "recharts"
import {
ChartConfig,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
} from "@/components/ui/interfaces-chart"
const chartData = [
{ browser: "chrome", visitors: 275, fill: "var(--chart-1)" },
{ browser: "safari", visitors: 200, fill: "var(--chart-2)" },
{ browser: "firefox", visitors: 187, fill: "var(--chart-3)" },
{ browser: "edge", visitors: 173, fill: "var(--chart-4)" },
{ browser: "other", visitors: 90, fill: "var(--chart-5)" },
]
const chartConfig = {
visitors: { label: "Visitors" },
chrome: { label: "Chrome" },
safari: { label: "Safari" },
firefox: { label: "Firefox" },
edge: { label: "Edge" },
other: { label: "Other" },
} satisfies ChartConfig
export default function ChartPieDemo() {
return (
<div className="flex w-full min-h-screen items-center justify-center overflow-hidden bg-background p-8">
<div className="w-full max-w-2xl rounded-2xl border bg-card p-6 shadow-sm">
<div className="mb-4">
<h3 className="text-lg font-semibold text-foreground">Pie Chart</h3>
<p className="text-sm text-muted-foreground">Browser usage — January 2024</p>
</div>
<ChartContainer config={chartConfig} className="mx-auto aspect-square max-h-[250px] w-full max-w-[320px]">
<PieChart>
<ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel nameKey="browser" />} />
<Pie
data={chartData}
dataKey="visitors"
nameKey="browser"
innerRadius={60}
strokeWidth={5}
/>
</PieChart>
</ChartContainer>
</div>
</div>
)
}
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...