Plot tab: HH:MM:SS x-axis ticks, date label in control bar

Replace pg.DateAxisItem with a custom TimeAxisItem that formats ticks
as HH:MM:SS, eliminating locale-dependent day/date prefixes on the axis.

Add a per-plot date label (right-aligned in the control bar) that shows
the date range of the visible window — single date when the view stays
within one day, "YYYY-MM-DD – YYYY-MM-DD" when it spans midnight.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 16:36:57 +02:00
co-authored by Claude Sonnet 4.6
parent 620d22d2e4
commit 5e2aa3f17d
+24 -2
View File
@@ -384,6 +384,12 @@ class DashboardTab(QWidget):
# ── Plot tab ──────────────────────────────────────────────────────────────────
class TimeAxisItem(pg.AxisItem):
"""X-axis that shows HH:MM:SS, suppressing any date prefix."""
def tickStrings(self, values, scale, spacing):
return [datetime.fromtimestamp(v).strftime("%H:%M:%S") for v in values]
class PlotTab(QWidget):
NUM_PLOTS = 8
MAX_TRACES = 4
@@ -421,6 +427,7 @@ class PlotTab(QWidget):
self._proxies: list = []
self._add_combos: list[QComboBox] = []
self._chip_bars: list[QHBoxLayout] = []
self._date_labels: list[QLabel] = []
for i in range(self.NUM_PLOTS):
cell = QWidget()
@@ -465,12 +472,18 @@ class PlotTab(QWidget):
ctrl_row.addLayout(chip_bar)
ctrl_row.addStretch()
date_lbl = QLabel("")
date_lbl.setStyleSheet("color: #666688; font-size: 10px;")
date_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self._date_labels.append(date_lbl)
ctrl_row.addWidget(date_lbl)
cell_vbox.addWidget(ctrl)
# plot
pw = pg.PlotWidget(
background="#12121e",
axisItems={"bottom": pg.DateAxisItem(orientation="bottom")},
axisItems={"bottom": TimeAxisItem(orientation="bottom")},
)
pw.showGrid(x=True, y=True, alpha=0.3)
pw.addLegend(offset=(0, 0), labelTextSize="8pt")
@@ -663,7 +676,16 @@ class PlotTab(QWidget):
name=label,
)
pw.setXRange(x_min if x_min is not None else cutoff, now, padding=0.02)
x_lo = x_min if x_min is not None else cutoff
pw.setXRange(x_lo, now, padding=0.02)
d_lo = datetime.fromtimestamp(x_lo).date()
d_hi = datetime.fromtimestamp(now).date()
if d_lo == d_hi:
date_str = d_lo.strftime("%Y-%m-%d")
else:
date_str = f"{d_lo.strftime('%Y-%m-%d')} {d_hi.strftime('%Y-%m-%d')}"
self._date_labels[i].setText(date_str)
# ── cursor tracing ────────────────────────────────────────────────────────