chart-pie-interactive.json — ui Source File
Architecture documentation for chart-pie-interactive.json, a json file in the ui codebase.
Entity Profile
Source Code
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "chart-pie-interactive",
"type": "registry:block",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"card",
"chart"
],
"files": [
{
"path": "charts/chart-pie-interactive.tsx",
"content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Label, Pie, PieChart, Sector } from \"recharts\"\nimport { PieSectorDataItem } from \"recharts/types/polar/Pie\"\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/registry/new-york/ui/card\"\nimport {\n ChartConfig,\n ChartContainer,\n ChartStyle,\n ChartTooltip,\n ChartTooltipContent,\n} from \"@/registry/new-york/ui/chart\"\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/registry/new-york/ui/select\"\nconst desktopData = [\n { month: \"january\", desktop: 186, fill: \"var(--color-january)\" },\n { month: \"february\", desktop: 305, fill: \"var(--color-february)\" },\n { month: \"march\", desktop: 237, fill: \"var(--color-march)\" },\n { month: \"april\", desktop: 173, fill: \"var(--color-april)\" },\n { month: \"may\", desktop: 209, fill: \"var(--color-may)\" },\n]\n\nconst chartConfig = {\n visitors: {\n label: \"Visitors\",\n },\n desktop: {\n label: \"Desktop\",\n },\n mobile: {\n label: \"Mobile\",\n },\n january: {\n label: \"January\",\n color: \"hsl(var(--chart-1))\",\n },\n february: {\n label: \"February\",\n color: \"hsl(var(--chart-2))\",\n },\n march: {\n label: \"March\",\n color: \"hsl(var(--chart-3))\",\n },\n april: {\n label: \"April\",\n color: \"hsl(var(--chart-4))\",\n },\n may: {\n label: \"May\",\n color: \"hsl(var(--chart-5))\",\n },\n} satisfies ChartConfig\n\nexport default function Component() {\n const id = \"pie-interactive\"\n const [activeMonth, setActiveMonth] = React.useState(desktopData[0].month)\n\n const activeIndex = React.useMemo(\n () => desktopData.findIndex((item) => item.month === activeMonth),\n [activeMonth]\n )\n const months = React.useMemo(() => desktopData.map((item) => item.month), [])\n\n return (\n <Card data-chart={id} className=\"flex flex-col\">\n <ChartStyle id={id} config={chartConfig} />\n <CardHeader className=\"flex-row items-start space-y-0 pb-0\">\n <div className=\"grid gap-1\">\n <CardTitle>Pie Chart - Interactive</CardTitle>\n <CardDescription>January - June 2024</CardDescription>\n </div>\n <Select value={activeMonth} onValueChange={setActiveMonth}>\n <SelectTrigger\n className=\"ml-auto h-7 w-[130px] rounded-lg pl-2.5\"\n aria-label=\"Select a value\"\n >\n <SelectValue placeholder=\"Select month\" />\n </SelectTrigger>\n <SelectContent align=\"end\" className=\"rounded-xl\">\n {months.map((key) => {\n const config = chartConfig[key as keyof typeof chartConfig]\n\n if (!config) {\n return null\n }\n\n return (\n <SelectItem\n key={key}\n value={key}\n className=\"rounded-lg [&_span]:flex\"\n >\n <div className=\"flex items-center gap-2 text-xs\">\n <span\n className=\"flex h-3 w-3 shrink-0 rounded-sm\"\n style={{\n backgroundColor: `var(--color-${key})`,\n }}\n />\n {config?.label}\n </div>\n </SelectItem>\n )\n })}\n </SelectContent>\n </Select>\n </CardHeader>\n <CardContent className=\"flex flex-1 justify-center pb-0\">\n <ChartContainer\n id={id}\n config={chartConfig}\n className=\"mx-auto aspect-square w-full max-w-[300px]\"\n >\n <PieChart>\n <ChartTooltip\n cursor={false}\n content={<ChartTooltipContent hideLabel />}\n />\n <Pie\n data={desktopData}\n dataKey=\"desktop\"\n nameKey=\"month\"\n innerRadius={60}\n strokeWidth={5}\n activeIndex={activeIndex}\n activeShape={({\n outerRadius = 0,\n ...props\n }: PieSectorDataItem) => (\n <g>\n <Sector {...props} outerRadius={outerRadius + 10} />\n <Sector\n {...props}\n outerRadius={outerRadius + 25}\n innerRadius={outerRadius + 12}\n />\n </g>\n )}\n >\n <Label\n content={({ viewBox }) => {\n if (viewBox && \"cx\" in viewBox && \"cy\" in viewBox) {\n return (\n <text\n x={viewBox.cx}\n y={viewBox.cy}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n >\n <tspan\n x={viewBox.cx}\n y={viewBox.cy}\n className=\"fill-foreground text-3xl font-bold\"\n >\n {desktopData[activeIndex].desktop.toLocaleString()}\n </tspan>\n <tspan\n x={viewBox.cx}\n y={(viewBox.cy || 0) + 24}\n className=\"fill-muted-foreground\"\n >\n Visitors\n </tspan>\n </text>\n )\n }\n }}\n />\n </Pie>\n </PieChart>\n </ChartContainer>\n </CardContent>\n </Card>\n )\n}\n",
"type": "registry:block",
"target": ""
}
],
"categories": [
"charts",
"charts-pie"
]
}
Source
Frequently Asked Questions
What does chart-pie-interactive.json do?
chart-pie-interactive.json is a source file in the ui codebase, written in json.
Where is chart-pie-interactive.json in the architecture?
chart-pie-interactive.json is located at apps/v4/public/r/styles/new-york/chart-pie-interactive.json (directory: apps/v4/public/r/styles/new-york).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free