Files
Checkmate/Client/src/Pages/PageSpeed/Details/Components/PageSpeedAreaChart/index.jsx
T

59 lines
1.3 KiB
React
Raw Normal View History

2025-01-28 15:42:46 -08:00
import ChartBox from "../../../../../Components/Charts/ChartBox";
import AreaChart from "../Charts/AreaChart";
import AreaChartLegend from "../Charts/AreaChartLegend";
2025-01-28 15:51:58 -08:00
import SkeletonLayout from "./skeleton";
2025-01-28 15:42:46 -08:00
import ScoreIcon from "../../../../../assets/icons/monitor-graph-line.svg?react";
import { Stack } from "@mui/material";
2025-01-28 15:51:58 -08:00
import PropTypes from "prop-types";
2025-01-28 15:42:46 -08:00
import { useTheme } from "@emotion/react";
const PageSpeedAreaChart = ({ shouldRender, monitor, metrics, handleMetrics }) => {
const theme = useTheme();
2025-01-28 15:51:58 -08:00
if (!shouldRender) {
return <SkeletonLayout />;
}
2025-01-28 15:42:46 -08:00
if (typeof monitor === "undefined") {
return null;
}
const data = monitor?.checks ? [...monitor.checks].reverse() : [];
return (
<Stack
direction="row"
gap={theme.spacing(10)}
>
<ChartBox
justifyContent="flex-start"
icon={<ScoreIcon />}
header="Score history"
height="100%"
borderRadiusRight={16}
Legend={
<AreaChartLegend
metrics={metrics}
handleMetrics={handleMetrics}
/>
}
>
<AreaChart
data={data}
monitor={monitor}
metrics={metrics}
/>
</ChartBox>
</Stack>
);
};
2025-01-28 15:51:58 -08:00
PageSpeedAreaChart.propTypes = {
shouldRender: PropTypes.bool,
monitor: PropTypes.object,
metrics: PropTypes.object,
handleMetrics: PropTypes.func,
};
2025-01-28 15:42:46 -08:00
export default PageSpeedAreaChart;