From f689b304c86231968439c54aeb35d47a7669c4cf Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Wed, 4 Sep 2024 21:41:16 -0400 Subject: [PATCH] Fixed area chart tooltip --- .../Charts/MonitorDetailsAreaChart/index.jsx | 61 +++++++++++++------ Client/src/Pages/Monitors/Details/index.jsx | 8 ++- Client/src/Pages/Monitors/Details/styled.jsx | 4 +- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx index 5b6b0dd74..68fdb1cd4 100644 --- a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx +++ b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx @@ -1,6 +1,6 @@ import PropTypes from "prop-types"; import { AreaChart, Area, XAxis, Tooltip, ResponsiveContainer } from "recharts"; -import { Box, Typography } from "@mui/material"; +import { Box, Stack, Typography } from "@mui/material"; import { useTheme } from "@emotion/react"; import "./index.css"; @@ -16,14 +16,15 @@ const CustomToolTip = ({ active, payload, label }) => { border: 1, borderColor: theme.palette.border.dark, borderRadius: theme.shape.borderRadius, - py: theme.spacing(6), - px: theme.spacing(8), + py: theme.spacing(2), + px: theme.spacing(4), }} > {new Date(label).toLocaleDateString("en-US", { @@ -38,15 +39,39 @@ const CustomToolTip = ({ active, payload, label }) => { hour12: true, // AM/PM format })} - - Response Time (ms): {payload[0].payload.originalResponseTime} - {" "} + + + + + Response Time + {" "} + + {payload[0].payload.originalResponseTime} + + {" "} + ms + + + + {/* Display original value */} ); @@ -67,10 +92,10 @@ const MonitorDetailsAreaChart = ({ checks }) => { const theme = useTheme(); return ( - + { } /> { data={[{ response: monitor?.periodAvgResponseTime }]} /> - + diff --git a/Client/src/Pages/Monitors/Details/styled.jsx b/Client/src/Pages/Monitors/Details/styled.jsx index b8de5edfc..99112802d 100644 --- a/Client/src/Pages/Monitors/Details/styled.jsx +++ b/Client/src/Pages/Monitors/Details/styled.jsx @@ -16,11 +16,11 @@ export const ChartBox = styled(Stack)(({ theme }) => ({ fontSize: 15, fontWeight: 500, }, - "& p": { + "& .MuiBox-root:not(.area-tooltip) p": { color: theme.palette.text.tertiary, fontSize: 13, }, - "& span": { + "& .MuiBox-root > span": { color: theme.palette.text.primary, fontSize: 20, "& span": {