feat: enhance statistics page with new charts and data visualizations including savings trend, category trends, and year-over-year comparisons

This commit is contained in:
Julien Froidefond
2025-11-30 17:05:03 +01:00
parent f366ea02c5
commit 00dd8fc335
7 changed files with 902 additions and 27 deletions

View File

@@ -0,0 +1,94 @@
"use client";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import {
LineChart,
Line,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
Legend,
} from "recharts";
interface IncomeExpenseTrendDataPoint {
month: string;
revenus: number;
depenses: number;
}
interface IncomeExpenseTrendChartProps {
data: IncomeExpenseTrendDataPoint[];
formatCurrency: (amount: number) => string;
}
export function IncomeExpenseTrendChart({
data,
formatCurrency,
}: IncomeExpenseTrendChartProps) {
return (
<Card>
<CardHeader>
<CardTitle>Tendances revenus et dépenses</CardTitle>
</CardHeader>
<CardContent>
{data.length > 0 ? (
<div className="h-[300px]">
<ResponsiveContainer width="100%" height="100%">
<LineChart data={data}>
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
<XAxis
dataKey="month"
className="text-xs"
interval="preserveStartEnd"
/>
<YAxis
className="text-xs"
width={80}
tickFormatter={(v) => {
if (Math.abs(v) >= 1000) {
return `${(v / 1000).toFixed(1)}k€`;
}
return `${Math.round(v)}`;
}}
tick={{ fill: "var(--muted-foreground)" }}
/>
<Tooltip
formatter={(value: number) => formatCurrency(value)}
contentStyle={{
backgroundColor: "var(--card)",
border: "1px solid var(--border)",
borderRadius: "8px",
}}
/>
<Legend />
<Line
type="monotone"
dataKey="revenus"
name="Revenus"
stroke="#22c55e"
strokeWidth={2}
dot={false}
/>
<Line
type="monotone"
dataKey="depenses"
name="Dépenses"
stroke="#ef4444"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</div>
) : (
<div className="h-[300px] flex items-center justify-center text-muted-foreground">
Pas de données pour cette période
</div>
)}
</CardContent>
</Card>
);
}