diff --git a/Client/src/Pages/PageSpeed/Details/Charts/AreaChart.jsx b/Client/src/Pages/PageSpeed/Details/Charts/AreaChart.jsx new file mode 100644 index 000000000..1c5c8df8a --- /dev/null +++ b/Client/src/Pages/PageSpeed/Details/Charts/AreaChart.jsx @@ -0,0 +1,109 @@ +import { + AreaChart, + Area, + XAxis, + Tooltip, + CartesianGrid, + ResponsiveContainer, +} from "recharts"; +import { useTheme } from "@emotion/react"; +import { useMemo } from "react"; + +const config = { + accessibility: { + id: "accessibility", + color: "primary", + }, + bestPractices: { + id: "bestPractices", + color: "warning", + }, + performance: { + id: "performance", + color: "success", + }, + seo: { + id: "seo", + color: "unresolved", + }, +}; + +const PagespeedDetailsAreaChart = ({ data }) => { + const formatDate = (timestamp) => { + const date = new Date(timestamp); + return date.toLocaleTimeString("en-US", { + hour: "numeric", + minute: "2-digit", + hour12: true, + }); + }; + + const memoizedData = useMemo(() => data, [data[0]]); + + const theme = useTheme(); + + return ( + + + + + + + {Object.values(config).map(({ id, color }) => { + const startColor = theme.palette[color].main; + const endColor = theme.palette[color].light; + + return ( + + + + + ); + })} + + {Object.keys(config).map((key) => { + const { color } = config[key]; + const strokeColor = theme.palette[color].main; + const activeDotColor = theme.palette[color].bg; + + return ( + + ); + })} + + + ); +}; + +export default PagespeedDetailsAreaChart; diff --git a/Client/src/Pages/PageSpeed/Details/index.jsx b/Client/src/Pages/PageSpeed/Details/index.jsx index 40d71dc5e..5fdc186b2 100644 --- a/Client/src/Pages/PageSpeed/Details/index.jsx +++ b/Client/src/Pages/PageSpeed/Details/index.jsx @@ -20,6 +20,7 @@ import PerformanceIcon from "../../../assets/icons/performance-report.svg?react" import PageSpeedLineChart from "../../../Components/Charts/PagespeedLineChart"; import Breadcrumbs from "../../../Components/Breadcrumbs"; import PulseDot from "../../../Components/Animated/PulseDot"; +import PagespeedDetailsAreaChart from "./Charts/AreaChart"; import "./index.css"; /** @@ -264,7 +265,7 @@ const PageSpeedDetails = () => { let loading = Object.keys(monitor).length === 0; const data = monitor?.checks ? [...monitor.checks].reverse() : []; - console.log(monitor); + console.log(data); const splitDuration = (duration) => { const { time, format } = formatDurationSplit(duration); @@ -407,16 +408,16 @@ const PageSpeedDetails = () => { Showing statistics for past 24 hours. - + Score history - + - + diff --git a/Client/src/Pages/PageSpeed/Details/styled.jsx b/Client/src/Pages/PageSpeed/Details/styled.jsx index b067efa22..a6c829061 100644 --- a/Client/src/Pages/PageSpeed/Details/styled.jsx +++ b/Client/src/Pages/PageSpeed/Details/styled.jsx @@ -1,7 +1,6 @@ import { Box, Stack, styled } from "@mui/material"; export const ChartBox = styled(Stack)(({ theme }) => ({ - flex: "1 30%", gap: theme.spacing(8), height: 300, minWidth: 250,