Преглед на файлове

Graph: Fixed issue when using zero as a grid threshold, Fixes #1309

Torkel Ödegaard преди 11 години
родител
ревизия
ffbbb5bc9e
променени са 3 файла, в които са добавени 17 реда и са изтрити 2 реда
  1. 1 0
      CHANGELOG.md
  2. 2 2
      src/app/panels/graph/graph.js
  3. 14 0
      src/test/specs/graph-specs.js

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@
 
 
 **Fixes**
 **Fixes**
 - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query
 - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query
+- [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold
 
 
 # 1.9.1 (2014-12-29)
 # 1.9.1 (2014-12-29)
 
 

+ 2 - 2
src/app/panels/graph/graph.js

@@ -260,14 +260,14 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
         }
         }
 
 
         function addGridThresholds(options, panel) {
         function addGridThresholds(options, panel) {
-          if (panel.grid.threshold1) {
+          if (_.isNumber(panel.grid.threshold1)) {
             var limit1 = panel.grid.thresholdLine ? panel.grid.threshold1 : (panel.grid.threshold2 || null);
             var limit1 = panel.grid.thresholdLine ? panel.grid.threshold1 : (panel.grid.threshold2 || null);
             options.grid.markings.push({
             options.grid.markings.push({
               yaxis: { from: panel.grid.threshold1, to: limit1 },
               yaxis: { from: panel.grid.threshold1, to: limit1 },
               color: panel.grid.threshold1Color
               color: panel.grid.threshold1Color
             });
             });
 
 
-            if (panel.grid.threshold2) {
+            if (_.isNumber(panel.grid.threshold2)) {
               var limit2;
               var limit2;
               if (panel.grid.thresholdLine) {
               if (panel.grid.thresholdLine) {
                 limit2 = panel.grid.threshold2;
                 limit2 = panel.grid.threshold2;

+ 14 - 0
src/test/specs/graph-specs.js

@@ -126,6 +126,20 @@ define([
       });
       });
     });
     });
 
 
+    graphScenario('grid thresholds from zero', function(ctx) {
+      ctx.setup(function(scope) {
+        scope.panel.grid = {
+          threshold1: 0,
+          threshold1Color: "#111",
+        };
+      });
+
+      it('should add grid markings', function() {
+        var markings = ctx.plotOptions.grid.markings;
+        expect(markings[0].yaxis.from).to.be(0);
+      });
+    });
+
     graphScenario('should use timeStep for barWidth', function(ctx) {
     graphScenario('should use timeStep for barWidth', function(ctx) {
       ctx.setup(function(scope, data) {
       ctx.setup(function(scope, data) {
         scope.panel.bars = true;
         scope.panel.bars = true;