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) {