ensure data[n].length aligns with timestamps.length

This commit is contained in:
Nick Krecklow 2020-06-10 18:18:27 -05:00
parent 6901497165
commit 084790a3ba
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94

@ -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