diff --git a/Client/src/Pages/DistributedUptime/Details/Components/DistributedUptimeResponseChart/index.jsx b/Client/src/Pages/DistributedUptime/Details/Components/DistributedUptimeResponseChart/index.jsx
index b57d0f9dc..88beb258d 100644
--- a/Client/src/Pages/DistributedUptime/Details/Components/DistributedUptimeResponseChart/index.jsx
+++ b/Client/src/Pages/DistributedUptime/Details/Components/DistributedUptimeResponseChart/index.jsx
@@ -1,225 +1,50 @@
-import PropTypes from "prop-types";
-import {
- AreaChart,
- Area,
- XAxis,
- Tooltip,
- CartesianGrid,
- ResponsiveContainer,
- Text,
-} from "recharts";
+//Components
+import { Stack, Switch, Typography } from "@mui/material";
+import { useState } from "react";
+import DistributedUptimeResponseAreaChart from "./Area";
+import DistributedUptimeResponseBarChart from "./Bar";
import ChartBox from "../../../../../Components/Charts/ChartBox";
import ResponseTimeIcon from "../../../../../assets/icons/response-time-icon.svg?react";
-import { Box, Stack, Typography } from "@mui/material";
-import { useTheme } from "@emotion/react";
-import { useState } from "react";
-import { useSelector } from "react-redux";
-import { formatDateWithTz } from "../../../../../Utils/timeUtils";
-
-const CustomToolTip = ({ active, payload, label }) => {
- const uiTimezone = useSelector((state) => state.ui.timezone);
- const theme = useTheme();
- if (active && payload && payload.length) {
- const responseTime = payload[0]?.payload?.originalAvgResponseTime
- ? payload[0]?.payload?.originalAvgResponseTime
- : (payload[0]?.payload?.avgResponseTime ?? 0);
- return (
-
-
- {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
-
-
-
-
-
- Response time
-
-
- {Math.floor(responseTime)}
-
- {" "}
- ms
-
-
-
-
- {/* Display original value */}
-
- );
- }
- return null;
-};
-
-CustomToolTip.propTypes = {
- active: PropTypes.bool,
- payload: PropTypes.arrayOf(
- PropTypes.shape({
- value: PropTypes.number,
- payload: PropTypes.shape({
- _id: PropTypes.string,
- avgResponseTime: PropTypes.number,
- originalAvgResponseTime: PropTypes.number,
- }),
- })
- ),
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
-};
-const CustomTick = ({ x, y, payload, index }) => {
- const theme = useTheme();
-
- const uiTimezone = useSelector((state) => state.ui.timezone);
- // Render nothing for the first tick
- if (index === 0) return null;
- return (
-
- {formatDateWithTz(payload?.value, "h:mm a", uiTimezone)}
-
- );
-};
-
-CustomTick.propTypes = {
- x: PropTypes.number,
- y: PropTypes.number,
- payload: PropTypes.object,
- index: PropTypes.number,
-};
+// Utils
+import PropTypes from "prop-types";
const DistributedUptimeResponseChart = ({ checks }) => {
- const theme = useTheme();
- const [isHovered, setIsHovered] = useState(false);
-
- if (checks.length === 0) return null;
+ const [chartType, setChartType] = useState("bar");
+ let Chart = null;
+ if (chartType === "area") {
+ Chart = DistributedUptimeResponseAreaChart;
+ }
+ if (chartType === "bar") {
+ Chart = DistributedUptimeResponseBarChart;
+ }
return (
- }
- header="Response Times"
- sx={{ padding: 0 }}
- >
-
+
- setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- >
-
-
-
-
-
-
-
- }
- minTickGap={0}
- axisLine={false}
- tickLine={false}
- height={20}
- />
- }
- wrapperStyle={{ pointerEvents: "none" }}
- />
-
-
-
-
+ Bar
+ setChartType(e.target.checked ? "area" : "bar")}
+ />
+ Area
+
+ }
+ header="Response Times"
+ sx={{ padding: 0 }}
+ >
+
+
+
);
};
DistributedUptimeResponseChart.propTypes = {
checks: PropTypes.array,
+ type: PropTypes.string,
};
export default DistributedUptimeResponseChart;