From db0a5bd53764bda40ceaeb7019819a14bc3dacfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 10 Oct 2014 10:45:34 -0400 Subject: [PATCH] Graph: fix for legend values min & max, avg & current when series only has null values, Closes #923 --- src/app/components/timeSeries.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/components/timeSeries.js b/src/app/components/timeSeries.js index ab8b9e89041..85f653d440d 100644 --- a/src/app/components/timeSeries.js +++ b/src/app/components/timeSeries.js @@ -63,8 +63,10 @@ function (_, kbn) { this.yaxis = this.info.yaxis; this.stats.total = 0; - this.stats.max = -212312321312; - this.stats.min = 212312321312; + this.stats.max = Number.MIN_VALUE; + this.stats.min = Number.MAX_VALUE; + this.stats.avg = null; + this.stats.current = null; var ignoreNulls = fillStyle === 'connected'; var nullAsZero = fillStyle === 'null as zero'; @@ -101,6 +103,9 @@ function (_, kbn) { this.stats.timeStep = result[1][0] - result[0][0]; } + if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; } + if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; } + if (result.length) { this.stats.avg = (this.stats.total / result.length); this.stats.current = result[result.length-1][1];