From a68e4d2460d156170b30a13ee0bd65c0ade5e892 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Tue, 12 May 2020 22:10:38 -0500 Subject: [PATCH] fix missing graphData culling behavior --- assets/js/graph.js | 15 +++++++++++++++ lib/time.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/assets/js/graph.js b/assets/js/graph.js index df1971d..12f109b 100644 --- a/assets/js/graph.js +++ b/assets/js/graph.js @@ -35,6 +35,21 @@ export class GraphDisplayManager { this._graphData[i].push(playerCounts[i]) } + // Trim all data arrays to only the relevant portion + // This keeps it in sync with backend data structures + const graphMaxLength = this._app.publicConfig.graphMaxLength + + if (this._graphTimestamps.length > graphMaxLength) { + this._graphTimestamps.splice(0, this._graphTimestamps.length - graphMaxLength) + } + + for (const series of this._graphData) { + if (series.length > graphMaxLength) { + series.splice(0, series.length - graphMaxLength) + } + } + + // Paint updated data structure this._plotInstance.setData([ this._graphTimestamps, ...this._graphData diff --git a/lib/time.js b/lib/time.js index 0165215..8736cfd 100644 --- a/lib/time.js +++ b/lib/time.js @@ -58,7 +58,7 @@ class TimeTracker { } static getMaxGraphDataLength () { - return Math.ceil(config.graphDuration / config.rates.pingAll) + return Math.ceil(config.graphDuration / GRAPH_UPDATE_TIME_GAP) } static everyN (array, start, diff, adapter) {