diff --git a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx
index 3256a53d6..91cb1bf22 100644
--- a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx
+++ b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx
@@ -13,15 +13,14 @@ import { useTheme } from "@emotion/react";
import { useMemo, useState } from "react";
import { useSelector } from "react-redux";
import { formatDateWithTz } from "../../../Utils/timeUtils";
+import {
+ tooltipDateFormatLookup,
+ tickDateFormatLookup,
+} from "../Utils/chartUtilFunctions";
+
import "./index.css";
-// ddd, MMMM D, YYYY, h:mm A
const CustomToolTip = ({ active, payload, label, dateRange }) => {
- const formatLookup = {
- day: "ddd. MMMM D, YYYY, hh:mm A",
- week: "ddd. MMMM D, YYYY, hh:mm A",
- month: "ddd. MMMM D, YYYY",
- };
- const format = formatLookup[dateRange];
+ const format = tooltipDateFormatLookup(dateRange);
const uiTimezone = useSelector((state) => state.ui.timezone);
const theme = useTheme();
if (active && payload && payload.length) {
@@ -111,12 +110,7 @@ CustomToolTip.propTypes = {
dateRange: PropTypes.string,
};
const CustomTick = ({ x, y, payload, index, dateRange }) => {
- const formatLookup = {
- day: "h:mm A",
- week: "MM/D, h:mm A",
- month: "ddd. M/D",
- };
- const format = formatLookup[dateRange];
+ const format = tickDateFormatLookup(dateRange);
const theme = useTheme();
const uiTimezone = useSelector((state) => state.ui.timezone);
return (
diff --git a/Client/src/Components/Charts/Utils/chartUtilFunctions.js b/Client/src/Components/Charts/Utils/chartUtilFunctions.js
new file mode 100644
index 000000000..70f5ac9c3
--- /dev/null
+++ b/Client/src/Components/Charts/Utils/chartUtilFunctions.js
@@ -0,0 +1,25 @@
+export const tooltipDateFormatLookup = (dateRange) => {
+ const dateFormatLookup = {
+ day: "ddd. MMMM D, YYYY, hh:mm A",
+ week: "ddd. MMMM D, YYYY, hh:mm A",
+ month: "ddd. MMMM D, YYYY",
+ };
+ const format = dateFormatLookup[dateRange];
+ if (format === undefined) {
+ return "";
+ }
+ return format;
+};
+
+export const tickDateFormatLookup = (dateRange) => {
+ const tickFormatLookup = {
+ day: "h:mm A",
+ week: "MM/D, h:mm A",
+ month: "ddd. M/D",
+ };
+ const format = tickFormatLookup[dateRange];
+ if (format === undefined) {
+ return "";
+ }
+ return format;
+};
diff --git a/Client/src/Components/Charts/Utils/chartUtils.jsx b/Client/src/Components/Charts/Utils/chartUtils.jsx
index 1d82f10b4..1776c75d9 100644
--- a/Client/src/Components/Charts/Utils/chartUtils.jsx
+++ b/Client/src/Components/Charts/Utils/chartUtils.jsx
@@ -4,7 +4,7 @@ import { useTheme } from "@mui/material";
import { Text } from "recharts";
import { formatDateWithTz } from "../../../Utils/timeUtils";
import { Box, Stack, Typography } from "@mui/material";
-
+import { tickDateFormatLookup, tooltipDateFormatLookup } from "./chartUtilFunctions";
/**
* Custom tick component for rendering time with timezone.
*
@@ -15,9 +15,10 @@ import { Box, Stack, Typography } from "@mui/material";
* @param {number} props.index - The index of the tick.
* @returns {JSX.Element} The rendered tick component.
*/
-export const TzTick = ({ x, y, payload, index }) => {
+export const TzTick = ({ x, y, payload, index, dateRange }) => {
const theme = useTheme();
const uiTimezone = useSelector((state) => state.ui.timezone);
+ const format = tickDateFormatLookup(dateRange);
return (
{
fontSize={11}
fontWeight={400}
>
- {formatDateWithTz(payload?.value, "h:mm a", uiTimezone)}
+ {formatDateWithTz(payload?.value, format, uiTimezone)}
);
};
@@ -37,6 +38,7 @@ TzTick.propTypes = {
y: PropTypes.number,
payload: PropTypes.object,
index: PropTypes.number,
+ dateRange: PropTypes.string,
};
/**
@@ -109,9 +111,12 @@ export const InfrastructureTooltip = ({
yIdx = -1,
yLabel,
dotColor,
+ dateRange,
}) => {
const uiTimezone = useSelector((state) => state.ui.timezone);
const theme = useTheme();
+
+ const format = tooltipDateFormatLookup(dateRange);
if (active && payload && payload.length) {
const [hardwareType, metric] = yKey.split(".");
return (
@@ -133,7 +138,7 @@ export const InfrastructureTooltip = ({
fontWeight: 500,
}}
>
- {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
+ {formatDateWithTz(label, format, uiTimezone)}
{
+export const TemperatureTooltip = ({
+ active,
+ payload,
+ label,
+ keys,
+ dotColor,
+ dateRange,
+}) => {
const uiTimezone = useSelector((state) => state.ui.timezone);
const theme = useTheme();
+ const format = tooltipDateFormatLookup(dateRange);
const formatCoreKey = (key) => {
return key.replace(/^core(\d+)$/, "Core $1");
};
@@ -213,7 +227,7 @@ export const TemperatureTooltip = ({ active, payload, label, keys, dotColor }) =
fontWeight: 500,
}}
>
- {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
+ {formatDateWithTz(label, format, uiTimezone)}
@@ -273,4 +287,6 @@ TemperatureTooltip.propTypes = {
PropTypes.string,
PropTypes.number,
]),
+ dotColor: PropTypes.string,
+ dateRange: PropTypes.string,
};
diff --git a/Client/src/Pages/Infrastructure/Details/index.jsx b/Client/src/Pages/Infrastructure/Details/index.jsx
index 29eddb9fc..5a0f59d5c 100644
--- a/Client/src/Pages/Infrastructure/Details/index.jsx
+++ b/Client/src/Pages/Infrastructure/Details/index.jsx
@@ -13,9 +13,8 @@ import { useNavigate } from "react-router-dom";
import Empty from "./empty";
import { logger } from "../../../Utils/Logger";
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
+import { TzTick, PercentTick } from "../../../Components/Charts/Utils/chartUtils";
import {
- TzTick,
- PercentTick,
InfrastructureTooltip,
TemperatureTooltip,
} from "../../../Components/Charts/Utils/chartUtils";
@@ -414,12 +413,13 @@ const InfrastructureDetails = () => {
yLabel: "Memory usage",
yDomain: [0, 1],
yTick: ,
- xTick: ,
+ xTick: ,
toolTip: (
),
},
@@ -433,12 +433,13 @@ const InfrastructureDetails = () => {
yLabel: "CPU usage",
yDomain: [0, 1],
yTick: ,
- xTick: ,
+ xTick: ,
toolTip: (
),
},
@@ -450,7 +451,7 @@ const InfrastructureDetails = () => {
gradientStartColor: theme.palette.error.main,
heading: "CPU Temperature",
yLabel: "Temperature",
- xTick: ,
+ xTick: ,
yDomain: [
0,
Math.max(
@@ -462,6 +463,7 @@ const InfrastructureDetails = () => {
),
},
@@ -476,13 +478,14 @@ const InfrastructureDetails = () => {
yLabel: "Disk Usage",
yDomain: [0, 1],
yTick: ,
- xTick: ,
+ xTick: ,
toolTip: (
),
})) || []),