mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
Standardize bar graph y axis (#13772)
* Standardize bar graph y axis * Fix lint
This commit is contained in:
parent
36d7eb7caa
commit
6bf2708c0e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user