From ac77a9d259382a9d9ea13855a34241755b6382b0 Mon Sep 17 00:00:00 2001 From: RKWojs Date: Fri, 14 Nov 2025 11:17:29 +0100 Subject: [PATCH] feat: enhance TeamLeadsDashboard with ComposedChart and improved tooltip for monthly and cumulative values --- src/app/dashboard/page.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/app/dashboard/page.js b/src/app/dashboard/page.js index 4935461..bc654c2 100644 --- a/src/app/dashboard/page.js +++ b/src/app/dashboard/page.js @@ -1,7 +1,7 @@ "use client"; import { useState, useEffect } from "react"; -import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; +import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, BarChart, Bar, ComposedChart } from 'recharts'; export default function TeamLeadsDashboard() { const [chartData, setChartData] = useState([]); @@ -38,14 +38,18 @@ export default function TeamLeadsDashboard() { const CustomTooltip = ({ active, payload, label }) => { if (active && payload && payload.length) { + // Find the monthly and cumulative values + const monthlyData = payload.find(p => p.dataKey === 'value'); + const cumulativeData = payload.find(p => p.dataKey === 'cumulative'); + return (

{`Month: ${label}`}

-

- {`Monthly Value: ${formatCurrency(payload[0].value)}`} +

+ {`Monthly Value: ${monthlyData ? formatCurrency(monthlyData.value) : 'N/A'}`}

-

- {`Cumulative: ${formatCurrency(payload[1].value)}`} +

+ {`Cumulative: ${cumulativeData ? formatCurrency(cumulativeData.value) : 'N/A'}`}

); @@ -79,10 +83,10 @@ export default function TeamLeadsDashboard() { ) : (
- } /> + - - +
)}