Skip to content

NVR with realtime local object detection for IP cameras

Standardize bar graph y axis (#13772)

Nicolas Mowen6bf2708c0e22
diff --git a/web/src/components/graph/SystemGraph.tsx b/web/src/components/graph/SystemGraph.tsx
index 3f5bfead30..098a1957e6 100644
--- a/web/src/components/graph/SystemGraph.tsx
+++ b/web/src/components/graph/SystemGraph.tsx
@@ -32,6 +32,16 @@ export function ThresholdBarGraph({
[data],
);
+ const yMax = useMemo(() => {
+ if (unit != "%") {
+ return undefined;
+ }
+
+ // @ts-expect-error y is valid
+ const yValues: number[] = data[0].data.map((point) => point?.y);
+ return Math.max(threshold.warning, ...yValues);
+ }, [data, threshold, unit]);
+
const { theme, systemTheme } = useTheme();
const formatTime = useCallback(
@@ -130,9 +140,10 @@ export function ThresholdBarGraph({
formatter: (val: number) => Math.ceil(val).toString(),
},
min: 0,
+ max: yMax,
},
} as ApexCharts.ApexOptions;
- }, [graphId, threshold, unit, systemTheme, theme, formatTime]);
+ }, [graphId, threshold, unit, yMax, systemTheme, theme, formatTime]);
useEffect(() => {
ApexCharts.exec(graphId, "updateOptions", options, true, true);