add legend
This commit is contained in:
1 parent
6856914d41
commit
89464e9be4
3 files changed
+65
-6
No files matched your search
@@ -1,18 +1,28 @@
|
|||||||
import type { CSSProperties } from "react";
|
import type { CSSProperties } from "react";
|
||||||
|
|
||||||
|
export const DotSizes = ["xs", "sm", "md", "lg"] as const;
|
||||||
|
export type DotSize = (typeof DotSizes)[number];
|
||||||
|
|
||||||
|
const DOT_SIZE_PX: Record<DotSize, string> = {
|
||||||
|
xs: "2px",
|
||||||
|
sm: "4px",
|
||||||
|
md: "8px",
|
||||||
|
lg: "12px",
|
||||||
|
};
|
||||||
|
|
||||||
interface DotProps {
|
interface DotProps {
|
||||||
color?: string;
|
color?: string;
|
||||||
size?: string;
|
size?: DotSize;
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Dot = ({ color = "gray", size = "4px", style }: DotProps) => {
|
export const Dot = ({ color = "gray", size = "sm", style }: DotProps) => {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
content: '""',
|
content: '""',
|
||||||
width: size,
|
width: DOT_SIZE_PX[size],
|
||||||
height: size,
|
height: DOT_SIZE_PX[size],
|
||||||
borderRadius: "50%",
|
borderRadius: "50%",
|
||||||
backgroundColor: color,
|
backgroundColor: color,
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import type { RootState } from "@/Types/state";
|
|||||||
import { computeYAxisCap } from "@/Components/monitors/charts/ChartUtils";
|
import { computeYAxisCap } from "@/Components/monitors/charts/ChartUtils";
|
||||||
|
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { SPACING } from "@/Utils/Theme/constants";
|
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
||||||
import {
|
import {
|
||||||
PHASE_COLOR_KEYS,
|
PHASE_COLOR_KEYS,
|
||||||
PHASE_KEYS,
|
PHASE_KEYS,
|
||||||
@@ -104,7 +104,7 @@ const TimingPhasesToolTip = ({
|
|||||||
gap={SPACING.LG}
|
gap={SPACING.LG}
|
||||||
>
|
>
|
||||||
<Dot
|
<Dot
|
||||||
size={"12px"}
|
size="lg"
|
||||||
color={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
|
color={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
@@ -128,6 +128,8 @@ export const HistogramDetails = ({
|
|||||||
range: string;
|
range: string;
|
||||||
}) => {
|
}) => {
|
||||||
const [showTimingPhases, setShowTimingPhases] = useState(false);
|
const [showTimingPhases, setShowTimingPhases] = useState(false);
|
||||||
|
const [hoveredPhase, setHoveredPhase] = useState<string | null>(null);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
|
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
|
||||||
@@ -267,6 +269,7 @@ export const HistogramDetails = ({
|
|||||||
{hasTimingPhases &&
|
{hasTimingPhases &&
|
||||||
showTimingPhases &&
|
showTimingPhases &&
|
||||||
PHASE_KEYS.map((key) => {
|
PHASE_KEYS.map((key) => {
|
||||||
|
const dimmed = hoveredPhase !== null && hoveredPhase !== key;
|
||||||
return (
|
return (
|
||||||
<Area
|
<Area
|
||||||
key={key}
|
key={key}
|
||||||
@@ -275,11 +278,56 @@ export const HistogramDetails = ({
|
|||||||
dataKey={key}
|
dataKey={key}
|
||||||
stroke={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
|
stroke={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
|
||||||
fill={`url(#phaseGradient-${key})`}
|
fill={`url(#phaseGradient-${key})`}
|
||||||
|
fillOpacity={dimmed ? 0.05 : undefined}
|
||||||
|
strokeOpacity={dimmed ? 0.05 : undefined}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
<Stack
|
||||||
|
justifyContent={"center"}
|
||||||
|
gap={LAYOUT.XS}
|
||||||
|
direction={"row"}
|
||||||
|
flexWrap={"wrap"}
|
||||||
|
>
|
||||||
|
{showTimingPhases ? (
|
||||||
|
PHASE_KEYS.map((key) => {
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={SPACING.LG}
|
||||||
|
key={key}
|
||||||
|
onMouseEnter={() => setHoveredPhase(key)}
|
||||||
|
onMouseLeave={() => setHoveredPhase(null)}
|
||||||
|
>
|
||||||
|
<Dot
|
||||||
|
color={theme.palette.chart.phases[PHASE_COLOR_KEYS[key]]}
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
<Typography lineHeight={1}>{t(PHASE_LABEL_KEYS[key])}</Typography>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={SPACING.LG}
|
||||||
|
onMouseEnter={() => setHoveredPhase("avgResponseTime")}
|
||||||
|
onMouseLeave={() => setHoveredPhase(null)}
|
||||||
|
>
|
||||||
|
<Dot
|
||||||
|
color={theme.palette.primary.main}
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
<Typography lineHeight={1}>
|
||||||
|
{t("common.charts.labels.totalResponseTime")}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</BaseChart>
|
</BaseChart>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -70,6 +70,7 @@
|
|||||||
"low": "Low",
|
"low": "Low",
|
||||||
"responseTime": "Response time",
|
"responseTime": "Response time",
|
||||||
"timingPhases": "Timing phases",
|
"timingPhases": "Timing phases",
|
||||||
|
"totalResponseTime": "Total response time",
|
||||||
"uptime": "Uptime"
|
"uptime": "Uptime"
|
||||||
},
|
},
|
||||||
"histogram": {
|
"histogram": {
|
||||||
|
|||||||
Reference in new issue
Block a user