From 2c1e75593cd2b181076250b5ec596a72acaba486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 6 May 2026 15:20:32 -0300 Subject: [PATCH] feat: increase chart container heights and implement dynamic colored tooltips --- src/pages/Dashboard.tsx | 24 +++++++++++++++--------- src/pages/ProductDetails.tsx | 22 ++++++++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index 229ca28..a076ca6 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -11,6 +11,19 @@ const COLORS = [ '#06b6d4', '#ec4899', '#eab308', '#6366f1', '#14b8a6' ]; +const CustomTooltip = ({ active, payload, label }: any) => { + if (active && payload && payload.length) { + const color = payload[0].payload?.fill || payload[0].color || '#9ECAE1'; + return ( +
+

{label}

+

Vendas: {payload[0].value}

+
+ ); + } + return null; +}; + const Dashboard = () => { const { dateRange, setDateRange, ordersData } = useOutletContext<{ dateRange: DateRange, setDateRange: (range: DateRange) => void, ordersData: OrderData[] }>(); @@ -101,7 +114,7 @@ const Dashboard = () => {

Produtos Mais Vendidos

-
+
@@ -113,14 +126,7 @@ const Dashboard = () => { height={120} /> - + } cursor={{ fill: '#222222' }} /> {salesByProduct.map((_, index) => ( diff --git a/src/pages/ProductDetails.tsx b/src/pages/ProductDetails.tsx index 5d524c4..41ad920 100644 --- a/src/pages/ProductDetails.tsx +++ b/src/pages/ProductDetails.tsx @@ -6,6 +6,18 @@ import DateRangePicker from '../components/DateRangePicker'; import type { OrderData, DateRange } from '../types'; import { parseOrderDate } from '../dataService'; +const CustomTooltip = ({ active, payload, label }: any) => { + if (active && payload && payload.length) { + return ( +
+

{label}

+

Vendas: {payload[0].value}

+
+ ); + } + return null; +}; + const ProductDetails = () => { const { id } = useParams<{ id: string }>(); const { dateRange, setDateRange, ordersData } = useOutletContext<{ dateRange: DateRange, setDateRange: (range: DateRange) => void, ordersData: OrderData[] }>(); @@ -106,7 +118,7 @@ const ProductDetails = () => {

Volume de Vendas por Data

-
+
@@ -118,13 +130,7 @@ const ProductDetails = () => { height={80} /> - + } cursor={{ fill: '#222222' }} />