From eaa200a766a03fd2411ba8f8cc7b39e8b61421bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 4 Jul 2014 11:50:11 +0200 Subject: [PATCH] Fix for Max legend value when max value is zero (Issue #460) --- CHANGELOG.md | 2 +- src/app/panels/graph/timeSeries.js | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ebcafedd18..3384d5af7f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ vNext **Fixes** - Fix formatting negative values (PR #545) - +- Fix for Max legend value when max value is zero (Issue #460) # 1.6.1 (2014-06-24) diff --git a/src/app/panels/graph/timeSeries.js b/src/app/panels/graph/timeSeries.js index 7bf692c789d..d7a8a2125de 100644 --- a/src/app/panels/graph/timeSeries.js +++ b/src/app/panels/graph/timeSeries.js @@ -20,17 +20,21 @@ function (_, kbn) { this.yaxis = this.info.yaxis; this.info.total = 0; - this.info.max = null; + this.info.max = -212312321312; this.info.min = 212312321312; - _.each(this.datapoints, function(valueArray) { - var currentTime = valueArray[1]; - var currentValue = valueArray[0]; + var ignoreNulls = fillStyle === 'connected'; + var nullAsZero = fillStyle === 'null as zero'; + var currentTime; + var currentValue; + + for (var i = 0; i < this.datapoints.length; i++) { + currentValue = this.datapoints[i][0]; + currentTime = this.datapoints[i][1]; + if (currentValue === null) { - if (fillStyle === 'connected') { - return; - } - if (fillStyle === 'null as zero') { + if (ignoreNulls) { continue; } + if (nullAsZero) { currentValue = 0; } } @@ -48,7 +52,7 @@ function (_, kbn) { } result.push([currentTime * 1000, currentValue]); - }, this); + } if (result.length > 2) { this.info.timeStep = result[1][0] - result[0][0];