"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { TrendingUp, TrendingDown } from "lucide-react"; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from "recharts"; interface SavingsTrendDataPoint { month: string; savings: number; cumulative: number; } interface SavingsTrendChartProps { data: SavingsTrendDataPoint[]; formatCurrency: (amount: number) => string; } export function SavingsTrendChart({ data, formatCurrency, }: SavingsTrendChartProps) { const latestSavings = data.length > 0 ? data[data.length - 1].savings : 0; const isPositive = latestSavings >= 0; return ( Évolution des économies
{isPositive ? ( ) : ( )} {formatCurrency(latestSavings)}
{data.length > 0 ? (
{ if (Math.abs(v) >= 1000) { return `${(v / 1000).toFixed(1)}k€`; } return `${Math.round(v)}€`; }} tick={{ fill: "var(--muted-foreground)" }} /> formatCurrency(value)} contentStyle={{ backgroundColor: "var(--card)", border: "1px solid var(--border)", borderRadius: "8px", }} />
) : (
Pas de données pour cette période
)}
); }