feat: wire ReplayStatsTracker into SessionController + complete GraphView.updateTrend

This commit is contained in:
jack
2026-06-20 18:28:55 -07:00
parent 7206334a27
commit 20a34e22ee
3 changed files with 73 additions and 0 deletions
@@ -164,3 +164,30 @@ class GraphView(QObject):
self._plot_window = None
self._plot_widget = None
self._series = []
@Slot(str)
def updateTrend(self, avgs_json: str) -> None:
"""Plot the running avg temp series."""
import json
if not self._plot_widget:
return
try:
avgs = json.loads(avgs_json)
except (json.JSONDecodeError, TypeError) as exc:
log.error("Failed to parse trend data: %s", exc)
return
if hasattr(self,'_trend_line') and self._trend_line is not None:
self._plot_widget.removeItem(self._trend_line)
if not avgs:
return
x = list(range(len(avgs)))
pen = pg.mkPen("#5B9DF5", width=2)
self._trend_line = self._plot_widget.plot(x, avgs, name="Average", pen=pen)
# Y-axis range with buffer
y_min, y_max = min(avgs), max(avgs)
buf = max((y_max - y_min) * 0.1, 1.0) if y_max > y_min else 5.0
self._plot_widget.setYRange(y_min - buf, y_max + buf)