"use client"; import { TrendingUp, BarChart3, PieChart } from "lucide-react"; import { Bar, BarChart, CartesianGrid, XAxis, YAxis, Pie, PieChart as RechartsPieChart, Cell, ResponsiveContainer, LabelList } from "recharts"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/components/ui/chart"; import { DashboardStats } from "@/lib/dashboard/service"; interface DashboardOverviewChartProps { data: DashboardStats[]; title: string; description?: string; } // 차트 설정 const chartConfig = { pending: { label: "대기", color: "hsl(var(--chart-1))", // 회색 계열 }, inProgress: { label: "진행중", color: "hsl(var(--chart-2))", // 파란색 계열 }, completed: { label: "완료", color: "hsl(var(--chart-3))", // 초록색 계열 }, } satisfies ChartConfig; // 파이 차트용 색상 const PIE_COLORS = { pending: "#6b7280", inProgress: "#3b82f6", completed: "#10b981" }; export function DashboardOverviewChart({ data, title, description }: DashboardOverviewChartProps) { // 바 차트용 데이터 변환 const barChartData = data.map(item => ({ name: item.displayName.length > 10 ? item.displayName.substring(0, 10) + "..." : item.displayName, fullName: item.displayName, pending: item.pending, inProgress: item.inProgress, completed: item.completed, total: item.total })); // 파이 차트용 데이터 (전체 요약) const totalPending = data.reduce((sum, item) => sum + item.pending, 0); const totalInProgress = data.reduce((sum, item) => sum + item.inProgress, 0); const totalCompleted = data.reduce((sum, item) => sum + item.completed, 0); const totalTasks = totalPending + totalInProgress + totalCompleted; const pieChartData = [ { name: "대기", value: totalPending, color: PIE_COLORS.pending }, { name: "진행중", value: totalInProgress, color: PIE_COLORS.inProgress }, { name: "완료", value: totalCompleted, color: PIE_COLORS.completed } ].filter(item => item.value > 0); // 완료율 계산 const completionRate = totalTasks > 0 ? Math.round((totalCompleted / totalTasks) * 100) : 0; const isImproving = completionRate > 50; // 50% 이상이면 개선으로 간주 return (
총 {totalTasks}건