diff --git a/assets/js/scale.js b/assets/js/scale.js index 01ecd7e..f3bd304 100644 --- a/assets/js/scale.js +++ b/assets/js/scale.js @@ -26,7 +26,7 @@ export class RelativeScale { } static scaleMatrix (data, tickCount, maxFactor) { - const max = Math.max(...data.flat()) + const max = Math.max(...data.flat().filter(val => val !== null)) return RelativeScale.scale([0, RelativeScale.isFiniteOrZero(max)], tickCount, maxFactor) } @@ -46,8 +46,8 @@ export class RelativeScale { max: 0 } } else { - const min = Math.min(...data) - const max = Math.max(...data) + const min = Math.min(...data.filter(val => val !== null)) + const max = Math.max(...data.filter(val => val !== null)) return { min: RelativeScale.isFiniteOrZero(min), diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index afb1924..cb7ed97 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,8 @@ +**5.5.2** *(June 12 2020)* +- Fixed ping errors causing server graphs (or the historical graph) to sometimes disappear. +- Fixed ping errors causing server graphs to reset their Y scale minimum to 0. +- Improved zoomed detection and updating of the historical graph with recommendations by [@leeoniya](https://github.com/leeoniya). + **5.5.1** *(June 10 2020)* - New tooltip hover design on the historical graph. It will highlight the server closest to your cursor. - Historical graph is now limited to 10,000 increments on the Y axis. This prevents servers with over 100,000 players forcing the graph into 100,000 increments. diff --git a/lib/servers.js b/lib/servers.js index 4568324..944cdb4 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -45,6 +45,10 @@ class ServerRegistration { getUpdate (timestamp, resp, err, version) { const update = {} + // Always append a playerCount value + // When resp is undefined (due to an error), playerCount will be null + update.playerCount = getPlayerCountOrNull(resp) + if (resp) { if (resp.version && this.updateProtocolVersionCompat(resp.version, version.protocolId, version.protocolIndex)) { // Append an updated version listing @@ -65,10 +69,6 @@ class ServerRegistration { update.favicon = this.getFaviconUrl() } - // Append a result object - // This filters out unwanted data from resp - update.playerCount = resp.players.online - if (config.logToDatabase) { // Update calculated graph peak regardless if the graph is being updated // This can cause a (harmless) desync between live and stored data, but it allows it to be more accurate for long surviving processes