'use client'; import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip, Legend, PieLabelRenderProps } from 'recharts'; import { Card } from '@/components/ui/Card'; import { getPriorityChartColor } from '@/lib/status-config'; interface PriorityData { priority: string; count: number; percentage: number; [key: string]: string | number; // Index signature pour Recharts } interface PriorityDistributionChartProps { data: PriorityData[]; title?: string; } // Couleurs importées depuis la configuration centralisée export function PriorityDistributionChart({ data, title = "Distribution des Priorités" }: PriorityDistributionChartProps) { // Tooltip personnalisé const CustomTooltip = ({ active, payload }: { active?: boolean; payload?: Array<{ payload: PriorityData }> }) => { if (active && payload && payload.length) { const data = payload[0].payload; return (

{data.priority}

{data.count} tâches ({data.percentage}%)

); } return null; }; // Légende personnalisée const CustomLegend = ({ payload }: { payload?: Array<{ value: string; color: string }> }) => { return (
{payload?.map((entry, index: number) => (
{entry.value}
))}
); }; // Label personnalisé pour afficher les pourcentages const renderLabel = (props: PieLabelRenderProps) => { const percentage = typeof props.percent === 'number' ? props.percent * 100 : 0; return percentage > 5 ? `${Math.round(percentage)}%` : ''; }; return (

{title}

{data.map((entry, index) => ( ))} } /> } />
); }