'use client' import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer, Legend, BarChart, Bar, XAxis, YAxis, CartesianGrid, } from 'recharts' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' interface DiversityData { total: number byCountry: { country: string; count: number; percentage: number }[] byCategory: { category: string; count: number; percentage: number }[] byOceanIssue: { issue: string; count: number; percentage: number }[] byTag: { tag: string; count: number; percentage: number }[] } interface DiversityMetricsProps { data: DiversityData } const PIE_COLORS = [ '#053d57', '#de0f1e', '#557f8c', '#f38a52', '#6ad82f', '#3be31e', '#c9c052', '#e6382f', '#ed6141', '#0bd90f', '#8884d8', '#82ca9d', '#ffc658', '#ff7c7c', '#8dd1e1', ] export function DiversityMetricsChart({ data }: DiversityMetricsProps) { if (data.total === 0) { return (

No project data available

) } // Top countries for pie chart (max 10, others grouped) const topCountries = data.byCountry.slice(0, 10) const otherCountries = data.byCountry.slice(10) const countryPieData = otherCountries.length > 0 ? [...topCountries, { country: 'Others', count: otherCountries.reduce((sum, c) => sum + c.count, 0), percentage: otherCountries.reduce((sum, c) => sum + c.percentage, 0), }] : topCountries return (
{/* Summary */}
{data.total}

Total Projects

{data.byCountry.length}

Countries Represented

{data.byCategory.length}

Categories

{data.byTag.length}

Unique Tags

{/* Country Distribution */} Geographic Distribution
{countryPieData.map((_, index) => ( ))}
{/* Category Distribution */} Competition Categories {data.byCategory.length > 0 ? (
) : (

No category data

)}
{/* Ocean Issues */} {data.byOceanIssue.length > 0 && ( Ocean Issues Addressed
)} {/* Tags Cloud */} {data.byTag.length > 0 && ( Project Tags
{data.byTag.slice(0, 30).map((tag) => ( {tag.tag} ({tag.count}) ))}
)}
) }