import { useTheme } from "@emotion/react"; import { Box, Stack, Tooltip, Typography } from "@mui/material"; import { formatDate } from "../../../Utils/timeUtils"; import { useEffect, useState } from "react"; import "./index.css"; const BarChart = ({ checks = [] }) => { const theme = useTheme(); const [animate, setAnimate] = useState(false); useEffect(() => { setAnimate(true); }); // set responseTime to average if there's only one check if (checks.length === 1) { checks[0] = { ...checks[0], responseTime: 50 }; } if (checks.length !== 25) { const placeholders = Array(25 - checks.length).fill("placeholder"); checks = [...checks, ...placeholders]; } return ( event.stopPropagation()} sx={{ cursor: "default", }} > {checks.map((check, index) => check === "placeholder" ? ( ) : ( {formatDate(new Date(check.createdAt), { year: undefined })} Response Time {check.originalResponseTime} {" "} ms } placement="top" key={`check-${check?._id}`} slotProps={{ popper: { className: "bar-tooltip", modifiers: [ { name: "offset", options: { offset: [0, -10], }, }, ], }, }} > .MuiBox-root": { filter: "brightness(0.8)", }, }} > ) )} ); }; export default BarChart;