From d46ba25addd9c1d85076b0796b2d2e553e6e84d5 Mon Sep 17 00:00:00 2001 From: Andrii Vorobiov Date: Mon, 8 Aug 2022 20:00:19 +0300 Subject: [PATCH] ui: fix time window selection with mouse on Metrics charts This patch fixes an issue that prevents proper time selection with mouse on Metrics charts. The root cause of it is updated time scale object didn't include correct value of `windowSize` that's used to calculate `start` position of time range. Release note (ui change): fix issue with incorrect start time position of selected time range on Metrics page. --- .../src/views/cluster/components/linegraph/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx index 6c8da288be35..770ccb89372a 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx @@ -207,9 +207,11 @@ export class LineGraph extends React.Component { start: moment.unix(start), end: moment.unix(end), }; + const seconds = moment.duration(moment.utc(end).diff(start)).asSeconds(); let newTimeScale: TimeScale = { - ...findClosestTimeScale(defaultTimeScaleOptions, end - start, start), + ...findClosestTimeScale(defaultTimeScaleOptions, seconds), key: "Custom", + windowSize: moment.duration(moment.unix(end).diff(moment.unix(start))), fixedWindowEnd: moment.unix(end), }; if (this.props.adjustTimeScaleOnChange) {