'use client';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, ReferenceLine } from 'recharts';
import { SprintVelocity } from '@/lib/types';
interface BurndownChartProps {
sprintHistory: SprintVelocity[];
className?: string;
}
interface BurndownDataPoint {
day: string;
remaining: number;
ideal: number;
actual: number;
}
export function BurndownChart({ sprintHistory, className }: BurndownChartProps) {
// Générer des données de burndown simulées pour le sprint actuel
const currentSprint = sprintHistory[sprintHistory.length - 1];
if (!currentSprint) {
return (
Aucun sprint disponible pour le burndown
);
}
// Simuler une progression de burndown sur 14 jours (sprint de 2 semaines)
const sprintDays = 14;
const totalWork = currentSprint.plannedPoints;
const completedWork = currentSprint.completedPoints;
const burndownData: BurndownDataPoint[] = [];
for (let day = 0; day <= sprintDays; day++) {
const idealRemaining = totalWork - (totalWork * day / sprintDays);
// Simuler une progression réaliste avec des variations
let actualRemaining = totalWork;
if (day > 0) {
const progressRate = completedWork / totalWork;
const expectedProgress = (totalWork * day / sprintDays) * progressRate;
// Ajouter un peu de variation réaliste
const variation = Math.sin(day * 0.3) * (totalWork * 0.05);
actualRemaining = Math.max(0, totalWork - expectedProgress + variation);
}
burndownData.push({
day: day === 0 ? 'Début' : day === sprintDays ? 'Fin' : `J${day}`,
remaining: Math.round(actualRemaining * 10) / 10,
ideal: Math.round(idealRemaining * 10) / 10,
actual: Math.round(actualRemaining * 10) / 10
});
}
const CustomTooltip = ({ active, payload, label }: {
active?: boolean;
payload?: Array<{ value: number; name: string; color: string }>;
label?: string
}) => {
if (active && payload && payload.length) {
return (
{label}
{payload.map((item, index) => (
{item.name === 'ideal' ? 'Idéal' : 'Réel'}:
{item.value} points
))}
);
}
return null;
};
return (
{/* Graphique */}
} />
{/* Ligne idéale de burndown */}
{/* Progression réelle */}
{/* Ligne de référence à 0 */}
{/* Légende visuelle */}
{/* Métriques */}
{currentSprint.plannedPoints}
Points planifiés
{currentSprint.completedPoints}
Points complétés
{currentSprint.completionRate}%
Taux de réussite
);
}