ソースを参照

Graph: Fix to legend value Max and negative values, Fixes #1136

Torkel Ödegaard 11 年 前
コミット
ed2ca5fced
3 ファイル変更11 行追加2 行削除
  1. 1 0
      CHANGELOG.md
  2. 2 2
      src/app/components/timeSeries.js
  3. 8 0
      src/test/specs/timeSeries-specs.js

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 - [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop
 - [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop
 - [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling
 - [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling
 - [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated
 - [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated
+- [Issue #1136](https://github.com/grafana/grafana/issues/1136). Graph: Fix to legend value Max and negative values
 
 
 # 1.9.0-rc1 (2014-11-17)
 # 1.9.0-rc1 (2014-11-17)
 
 

+ 2 - 2
src/app/components/timeSeries.js

@@ -64,7 +64,7 @@ function (_, kbn) {
     var result = [];
     var result = [];
 
 
     this.stats.total = 0;
     this.stats.total = 0;
-    this.stats.max = Number.MIN_VALUE;
+    this.stats.max = -Number.MAX_VALUE;
     this.stats.min = Number.MAX_VALUE;
     this.stats.min = Number.MAX_VALUE;
     this.stats.avg = null;
     this.stats.avg = null;
     this.stats.current = null;
     this.stats.current = null;
@@ -106,7 +106,7 @@ function (_, kbn) {
       this.stats.timeStep = this.datapoints[1][1] - this.datapoints[0][1];
       this.stats.timeStep = this.datapoints[1][1] - this.datapoints[0][1];
     }
     }
 
 
-    if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; }
+    if (this.stats.max === -Number.MAX_VALUE) { this.stats.max = null; }
     if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; }
     if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; }
 
 
     if (result.length) {
     if (result.length) {

+ 8 - 0
src/test/specs/timeSeries-specs.js

@@ -35,6 +35,14 @@ define([
         expect(series.stats.current).to.be(10);
         expect(series.stats.current).to.be(10);
       });
       });
 
 
+      it('max value should work for negative values', function() {
+        series = new TimeSeries({
+          datapoints: [[-10,1], [-4, 2]]
+        });
+        series.getFlotPairs('null', yAxisFormats);
+        expect(series.stats.max).to.be(-4);
+      });
+
     });
     });
 
 
     describe('series overrides', function() {
     describe('series overrides', function() {