Added tooltips to each individual bar
This commit is contained in:
1 parent
c3f964a2e2
commit
ec79bcd500
3 files changed
+97
-18
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
.bar-tooltip .MuiTooltip-tooltip {
|
||||||
|
background-color: white;
|
||||||
|
border: solid 1px black;
|
||||||
|
box-shadow: var(--env-var-shadow-1);
|
||||||
|
border: solid 1px var(--env-var-color-6);
|
||||||
|
border-radius: var(--env-var-radius-1);
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar-tooltip .MuiTooltip-tooltip p {
|
||||||
|
font-size: var(--env-var-font-size-small-plus);
|
||||||
|
color: var(--env-var-color-2);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.bar-tooltip .MuiTooltip-tooltip span {
|
||||||
|
font-size: var(--env-var-font-size-small);
|
||||||
|
color: var(--env-var-color-2);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Stack } from "@mui/material";
|
import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
||||||
|
import { formatDate } from "../../../Utils/timeUtils";
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
const BarChart = ({ checks = [] }) => {
|
const BarChart = ({ checks = [] }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -7,31 +9,88 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
return (
|
return (
|
||||||
<Stack direction="row" flexWrap="nowrap" gap={theme.gap.xs} height="50px">
|
<Stack direction="row" flexWrap="nowrap" gap={theme.gap.xs} height="50px">
|
||||||
{checks.map((check) => (
|
{checks.map((check) => (
|
||||||
<Box
|
<Tooltip
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
<Typography>
|
||||||
|
{formatDate(new Date(check.createdAt), { year: undefined })}
|
||||||
|
</Typography>
|
||||||
|
<Box mt={theme.gap.xs}>
|
||||||
|
<Box
|
||||||
|
display="inline-block"
|
||||||
|
width={theme.gap.small}
|
||||||
|
height={theme.gap.small}
|
||||||
|
backgroundColor={
|
||||||
|
check.status
|
||||||
|
? theme.label.up.dotColor
|
||||||
|
: theme.label.down.dotColor
|
||||||
|
}
|
||||||
|
sx={{ borderRadius: "50%" }}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
display="inline-flex"
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
ml={theme.gap.xs}
|
||||||
|
gap={theme.gap.large}
|
||||||
|
>
|
||||||
|
<Typography component="span" sx={{ opacity: 0.8 }}>
|
||||||
|
Response Time
|
||||||
|
</Typography>
|
||||||
|
<Typography component="span">
|
||||||
|
{check.originalResponseTime}
|
||||||
|
<Typography component="span" sx={{ opacity: 0.8 }}>
|
||||||
|
{" "}
|
||||||
|
ms
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
placement="top"
|
||||||
key={`check-${check?._id}`}
|
key={`check-${check?._id}`}
|
||||||
position="relative"
|
slotProps={{
|
||||||
width="8px"
|
popper: {
|
||||||
height="100%"
|
className: "bar-tooltip",
|
||||||
backgroundColor="#f4f4f4"
|
modifiers: [
|
||||||
sx={{
|
{
|
||||||
borderRadius: theme.gap.xs,
|
name: "offset",
|
||||||
|
options: {
|
||||||
|
offset: [0, -12],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
position="absolute"
|
position="relative"
|
||||||
bottom={0}
|
width="8px"
|
||||||
width="100%"
|
height="100%"
|
||||||
height={`${check.responseTime}%`}
|
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status === true
|
check.status ? theme.label.up.bgColor : theme.label.down.bgColor
|
||||||
? "var(--env-var-color-23)"
|
|
||||||
: "var(--env-var-color-24)"
|
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: theme.gap.xs,
|
borderRadius: theme.gap.xs,
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
</Box>
|
<Box
|
||||||
|
position="absolute"
|
||||||
|
bottom={0}
|
||||||
|
width="100%"
|
||||||
|
height={`${check.responseTime}%`}
|
||||||
|
backgroundColor={
|
||||||
|
check.status
|
||||||
|
? theme.label.up.dotColor
|
||||||
|
: theme.label.down.dotColor
|
||||||
|
}
|
||||||
|
sx={{
|
||||||
|
borderRadius: theme.gap.xs,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export const formatDurationRounded = (ms) => {
|
|||||||
return time;
|
return time;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatDate = (date) => {
|
export const formatDate = (date, customOptions) => {
|
||||||
const options = {
|
const options = {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
@@ -51,6 +51,7 @@ export const formatDate = (date) => {
|
|||||||
hour: "numeric",
|
hour: "numeric",
|
||||||
minute: "numeric",
|
minute: "numeric",
|
||||||
hour12: true,
|
hour12: true,
|
||||||
|
...customOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the date using the specified options
|
// Return the date using the specified options
|
||||||
|
|||||||
Reference in new issue
Block a user