(ui): Fix QueueSizeMetricsChart

This commit is contained in:
Ken Hibino
2021-12-01 19:06:51 -08:00
parent f304d97e11
commit c8cbc49122
2 changed files with 18 additions and 1 deletions

View File

@@ -13,6 +13,10 @@ import { Metrics } from "../api";
interface Props {
data: Metrics[];
// both startTime and endTime are in unix time (seconds)
startTime: number;
endTime: number;
}
// interface that rechart understands.
@@ -58,9 +62,12 @@ function QueueSizeMetricsChart(props: Props) {
<XAxis
minTickGap={10}
dataKey="timestamp"
domain={[props.startTime, props.endTime]}
tickFormatter={(timestamp: number) =>
new Date(timestamp * 1000).toLocaleTimeString()
}
type="number"
scale="time"
/>
<YAxis />
<Tooltip

View File

@@ -140,6 +140,8 @@ function MetricsView(props: Props) {
}
}, [pollInterval, getMetricsAsync, durationSec, endTimeSec, endTimeOption]);
const now = currentUnixtime();
return (
<Container maxWidth="lg" className={classes.container}>
<Grid container spacing={3}>
@@ -322,7 +324,15 @@ function MetricsView(props: Props) {
</Grid>
<Grid item xs={12}>
<Typography>Queue Size</Typography>
<QueueSizeMetricsChart data={data?.data.result || []} />
<QueueSizeMetricsChart
data={data?.data.result || []}
endTime={endTimeOption === "real_time" ? now : endTimeSec}
startTime={
endTimeOption === "real_time"
? now - durationSec
: endTimeSec - durationSec
}
/>
</Grid>
</Grid>
<Grid item xs={12}>