From 084790a3ba7c6dceee8ea86205f494325419b62a Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Wed, 10 Jun 2020 18:18:27 -0500 Subject: [PATCH] ensure data[n].length aligns with timestamps.length --- assets/js/graph.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/assets/js/graph.js b/assets/js/graph.js index 2681a99..123952a 100644 --- a/assets/js/graph.js +++ b/assets/js/graph.js @@ -177,6 +177,19 @@ export class GraphDisplayManager { this.loadLocalStorage() } + for (const playerCounts of data) { + // Each playerCounts value corresponds to a ServerRegistration + // Require each array is the length of timestamps, if not, pad at the start with null values to fit to length + // This ensures newer ServerRegistrations do not left align due to a lower length + const lengthDiff = timestamps.length - playerCounts.length + + if (lengthDiff > 0) { + const padding = Array(lengthDiff).fill(null) + + playerCounts.unshift(...padding) + } + } + this._graphTimestamps = timestamps this._graphData = data