"use client"; import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, } from "@/components/ui/chart"; import { cn } from "@/lib/utils"; interface ChartCard11Props { title?: string; description?: string; className?: string; } const percentFormatter = new Intl.NumberFormat("fa-IR", { style: "percent", maximumFractionDigits: 0, }); const formatPercent = (value: number) => { const ratio = value <= 1 ? value : value / 100; return percentFormatter.format(ratio); }; const chartData = [ { category: "الکترونیک", inStock: 65, lowStock: 20, outOfStock: 15 }, { category: "پوشاک", inStock: 72, lowStock: 18, outOfStock: 10 }, { category: "خانه", inStock: 58, lowStock: 25, outOfStock: 17 }, { category: "ورزش", inStock: 80, lowStock: 12, outOfStock: 8 }, { category: "کتاب", inStock: 45, lowStock: 35, outOfStock: 20 }, ]; const chartConfig = { inStock: { label: "موجود", color: "var(--chart-1)", }, lowStock: { label: "کم‌موجود", color: "var(--chart-4)", }, outOfStock: { label: "ناموجود", color: "var(--chart-5)", }, } satisfies ChartConfig; const ChartCard11 = ({ title = "وضعیت موجودی", description = "سطح موجودی به تفکیک دسته (درصد)", className, }: ChartCard11Props) => { return ( {title} {description} formatPercent(Number(value))} /> ( {chartConfig[name as keyof typeof chartConfig]?.label}:{" "} {formatPercent(Number(value))} )} /> } cursor={{ fillOpacity: 0.05 }} /> } /> ); }; export { ChartCard11 };