From a87f0604587ca6ad9d00ee1c0fb80c5263cb1edb Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 11 May 2024 15:18:10 +0200 Subject: [PATCH] visualizer: limit history plot to 300 packets The drawing gets slow with too many points. --- impl/utils/visualizer/static/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/impl/utils/visualizer/static/index.js b/impl/utils/visualizer/static/index.js index fa76e17..b463c02 100644 --- a/impl/utils/visualizer/static/index.js +++ b/impl/utils/visualizer/static/index.js @@ -3,6 +3,7 @@ const traceEvent = Symbol('trace-event'); const tracePacket = Symbol('trace-packet'); const traceMaxEvents = 200; +const historyMaxPackets = 300; const state = { @@ -171,12 +172,21 @@ function addHistory(packet) { } } + // Limit to historyMaxPackets items + const shift = chartHistoryHz.data.labels.length == historyMaxPackets; + if (shift) { + chartHistory.data.labels.shift(); + } + let i = 0; for (const x of keys) { let data = packet[x]; if (data == -1e38 /* "NaN" */) { data = undefined; } + if (shift) { + chartHistory.data.datasets[i].data.shift(); + } chartHistory.data.datasets[i].data.push(data); i++; }