gui_client: fit x-axis to actual data when less than window size
Track the earliest timestamp across plotted traces (starting from None, not cutoff) so setXRange uses the first real data point as the left bound — no empty gap when data doesn't fill the full time window. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -615,6 +615,7 @@ class PlotTab(QWidget):
|
|||||||
if pi.legend:
|
if pi.legend:
|
||||||
pi.legend.clear()
|
pi.legend.clear()
|
||||||
|
|
||||||
|
x_min = None
|
||||||
for j, key in enumerate(self._traces[i]):
|
for j, key in enumerate(self._traces[i]):
|
||||||
if key not in self._series:
|
if key not in self._series:
|
||||||
continue
|
continue
|
||||||
@@ -622,6 +623,7 @@ class PlotTab(QWidget):
|
|||||||
if not series:
|
if not series:
|
||||||
continue
|
continue
|
||||||
times, values = zip(*series)
|
times, values = zip(*series)
|
||||||
|
x_min = times[0] if x_min is None else min(x_min, times[0])
|
||||||
label = f"{_trace_label(key)} [{self._units.get(key, '')}]"
|
label = f"{_trace_label(key)} [{self._units.get(key, '')}]"
|
||||||
pw.plot(
|
pw.plot(
|
||||||
list(times), list(values),
|
list(times), list(values),
|
||||||
@@ -629,7 +631,7 @@ class PlotTab(QWidget):
|
|||||||
name=label,
|
name=label,
|
||||||
)
|
)
|
||||||
|
|
||||||
pw.setXRange(cutoff, now, padding=0.02)
|
pw.setXRange(x_min if x_min is not None else cutoff, now, padding=0.02)
|
||||||
|
|
||||||
# ── cursor tracing ────────────────────────────────────────────────────────
|
# ── cursor tracing ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user