visualizer: limit history plot to 300 packets
The drawing gets slow with too many points.
This commit is contained in:
parent
a633838a7f
commit
a87f060458
|
@ -3,6 +3,7 @@ const traceEvent = Symbol('trace-event');
|
||||||
const tracePacket = Symbol('trace-packet');
|
const tracePacket = Symbol('trace-packet');
|
||||||
|
|
||||||
const traceMaxEvents = 200;
|
const traceMaxEvents = 200;
|
||||||
|
const historyMaxPackets = 300;
|
||||||
|
|
||||||
|
|
||||||
const state = {
|
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;
|
let i = 0;
|
||||||
for (const x of keys) {
|
for (const x of keys) {
|
||||||
let data = packet[x];
|
let data = packet[x];
|
||||||
if (data == -1e38 /* "NaN" */) {
|
if (data == -1e38 /* "NaN" */) {
|
||||||
data = undefined;
|
data = undefined;
|
||||||
}
|
}
|
||||||
|
if (shift) {
|
||||||
|
chartHistory.data.datasets[i].data.shift();
|
||||||
|
}
|
||||||
chartHistory.data.datasets[i].data.push(data);
|
chartHistory.data.datasets[i].data.push(data);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue