'use client' import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Cell, ReferenceLine, } from 'recharts' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' interface ProjectRankingData { id: string title: string teamName: string | null status: string averageScore: number | null evaluationCount: number } interface ProjectRankingsProps { data: ProjectRankingData[] limit?: number } // Generate color based on score (red to green gradient) const getScoreColor = (score: number): string => { if (score >= 8) return '#0bd90f' // Excellent - green if (score >= 6) return '#82ca9d' // Good - light green if (score >= 4) return '#ffc658' // Average - yellow if (score >= 2) return '#ff7300' // Poor - orange return '#de0f1e' // Very poor - red } export function ProjectRankingsChart({ data, limit = 20, }: ProjectRankingsProps) { const displayData = data.slice(0, limit).map((d, index) => ({ ...d, rank: index + 1, displayTitle: d.title.length > 25 ? d.title.substring(0, 25) + '...' : d.title, score: d.averageScore || 0, })) const averageScore = data.length > 0 ? data.reduce((sum, d) => sum + (d.averageScore || 0), 0) / data.length : 0 return ( Project Rankings Top {displayData.length} of {data.length} projects
[(value ?? 0).toFixed(2), 'Average Score']} labelFormatter={(_, payload) => { if (payload && payload[0]) { const item = payload[0].payload as ProjectRankingData & { rank: number } return `#${item.rank} - ${item.title}${item.teamName ? ` (${item.teamName})` : ''}` } return '' }} /> {displayData.map((entry, index) => ( ))}
) }