From 8a4f6d31b883e57707956ee5785115ee71773c68 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Tue, 23 Dec 2025 12:28:13 +0100 Subject: [PATCH] feat: enhance tooltip and global styles for improved visibility; implement custom tooltip rendering in CategoryTrendChart and enforce opacity settings in globals.css for Radix Portal and Recharts tooltips --- app/globals.css | 23 ++++++ .../statistics/category-trend-chart.tsx | 73 +++++++++++++++++-- 2 files changed, 89 insertions(+), 7 deletions(-) diff --git a/app/globals.css b/app/globals.css index fca1f69..95dfd26 100644 --- a/app/globals.css +++ b/app/globals.css @@ -381,6 +381,29 @@ opacity: 1 !important; } + /* Forcer l'opacité sur les wrappers Radix Portal */ + [data-radix-portal], + [data-radix-portal] > *, + [data-radix-popper-content-wrapper], + [data-radix-popper-content-wrapper] > * { + opacity: 1 !important; + } + + /* Forcer l'opacité sur les tooltips Recharts */ + .recharts-tooltip-wrapper, + .recharts-tooltip-wrapper > *, + .recharts-tooltip-wrapper > div, + .recharts-tooltip-wrapper > div > *, + .recharts-tooltip-cursor { + opacity: 1 !important; + } + + /* Forcer l'opacité et le background opaque sur le contenu du tooltip */ + .recharts-tooltip-wrapper > div { + background-color: var(--background) !important; + opacity: 1 !important; + } + /* Glassmorphism effect très prononcé */ .glass { background: var(--card); diff --git a/components/statistics/category-trend-chart.tsx b/components/statistics/category-trend-chart.tsx index 689754d..96de283 100644 --- a/components/statistics/category-trend-chart.tsx +++ b/components/statistics/category-trend-chart.tsx @@ -166,11 +166,67 @@ export function CategoryTrendChart({ tick={{ fill: "var(--muted-foreground)" }} /> formatCurrency(value)} - contentStyle={{ - backgroundColor: "var(--card)", - border: "1px solid var(--border)", - borderRadius: "8px", + content={({ active, payload, label }) => { + if (!active || !payload?.length) return null; + + // Filtrer seulement les catégories qui ont une valeur + const entriesWithValue = payload.filter( + (entry) => entry.value !== undefined && entry.value !== null && Number(entry.value) !== 0 + ); + + if (entriesWithValue.length === 0) return null; + + return ( +
+
+ {label} +
+
+ {entriesWithValue.map((entry, index) => { + const categoryId = entry.dataKey as string; + const categoryInfo = getCategoryInfo(categoryId); + const categoryName = getCategoryName(categoryId); + const value = entry.value as number; + + return ( +
+ {categoryInfo ? ( + + ) : ( +
+ )} + + {categoryName} + + + {formatCurrency(value)} + +
+ ); + })} +
+
+ ); + }} + wrapperStyle={{ + opacity: 1, }} /> - {allCategoryIds.map((categoryId) => { +
+
+ {allCategoryIds.map((categoryId) => { const categoryInfo = getCategoryInfo(categoryId); const categoryName = getCategoryName(categoryId); if (!categoryInfo && categoryId !== "uncategorized") @@ -233,6 +290,7 @@ export function CategoryTrendChart({ ); })} +
); }} @@ -259,6 +317,7 @@ export function CategoryTrendChart({ strokeWidth={isSelected ? 2 : 1} strokeOpacity={isSelected ? 1 : 0.3} dot={false} + connectNulls={true} hide={!isSelected && selectedCategories.length > 0} /> );