Browse Source

Web: fix trend min/max range to include both rx and tx for packets series

The packets series is serialized as 3-element points [timestamp, rx, tx]
by buildSeriesJson() since b64d57f, unlike other series which use
[timestamp, value].

The min/max range display in renderTrendResult() was using p[1] for all
series, which for packets only captured the rx delta, ignoring tx.

Fix by selecting the mapper function based on the series key: for
"packets", sum p[1] + p[2] (rx + tx); for all other series, use p[1]
as before.  This matches the existing pattern already used in
drawSparkline() (line 1890).
Valentin V. Bartenev 2 months ago
parent
commit
21e396366c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/helpers/web/WebPanelServer.cpp

+ 1 - 1
src/helpers/web/WebPanelServer.cpp

@@ -2074,7 +2074,7 @@ const char kWebPanelAppHtml[] PROGMEM = R"HTML(
       }
       const rangeEl = document.getElementById("head-range-" + key);
       if (rangeEl && points.length) {
-        const values = points.map((p) => p[1]).filter((v) => Number.isFinite(v));
+        const values = points.map(key === "packets" ? ((p) => p[1] + p[2]) : ((p) => p[1])).filter((v) => Number.isFinite(v));
         if (values.length) {
           rangeEl.textContent = "min " + formatTrendValue(key, Math.min(...values), false) + " / max " + formatTrendValue(key, Math.max(...values), false);
         }