diff --git a/src/client/app/components/LineChartComponent.tsx b/src/client/app/components/LineChartComponent.tsx
index 4001bbc96..7fc242997 100644
--- a/src/client/app/components/LineChartComponent.tsx
+++ b/src/client/app/components/LineChartComponent.tsx
@@ -111,6 +111,31 @@ export default function LineChartComponent() {
} else if (!enoughData) {
return
{`${translate('no.data.in.range')}`}
;
} else {
+ let minDate = '';
+ let maxDate = '';
+ for (const trace of data) {
+ if (trace.x && trace.x.length > 0) {
+ const traceMin = trace.x[0] as string;
+ const traceMax = trace.x[trace.x.length - 1] as string;
+ // Update minX if this is the first trace or has an earlier date
+ if (minDate === '' || utc(traceMin).isBefore(utc(minDate))) {
+ minDate = traceMin;
+ }
+ // Update maxX if this is the first trace or has a later date
+ if (maxDate === '' || utc(traceMax).isAfter(utc(maxDate))) {
+ maxDate = traceMax;
+ }
+ }
+ }
+ // Tries to get the range from the slider range interval, undefined if not bounded
+ const sliderRange: [string, string] | undefined = sliderRangeInterval?.getIsBounded()
+ ? [
+ sliderRangeInterval.getStartTimestamp()!.utc().toISOString(),
+ sliderRangeInterval.getEndTimestamp()!.utc().toISOString()
+ ]
+ : undefined;
+ // Either sets the xRange to the minDate maxDate or the saved slider range. This keeps the range from resetting when we toggle error bars.
+ const xRange: [string, string] = sliderRange ?? [minDate, maxDate];
return (