Explorar el Código

Fixed bug in singlestat panel and null value handling, #2189

Torkel Ödegaard hace 10 años
padre
commit
261e5ebbd4
Se han modificado 2 ficheros con 7 adiciones y 1 borrados
  1. 1 0
      public/app/components/kbn.js
  2. 6 1
      public/test/specs/kbn-format-specs.js

+ 1 - 0
public/app/components/kbn.js

@@ -406,6 +406,7 @@ function($, _, moment) {
   kbn.valueFormats.velocityknot = function(value, decimals) { return kbn.toFixed(value, decimals) + ' kn'; };
   kbn.valueFormats.velocityknot = function(value, decimals) { return kbn.toFixed(value, decimals) + ' kn'; };
 
 
   kbn.roundValue = function (num, decimals) {
   kbn.roundValue = function (num, decimals) {
+    if (num === null) { return null; }
     var n = Math.pow(10, decimals);
     var n = Math.pow(10, decimals);
     return Math.round((n * num).toFixed(decimals))  / n;
     return Math.round((n * num).toFixed(decimals))  / n;
   };
   };

+ 6 - 1
public/test/specs/kbn-format-specs.js

@@ -51,7 +51,12 @@ define([
     });
     });
   });
   });
 
 
-
+  describe('kbn roundValue', function() {
+    it('should should handle null value', function() {
+      var str = kbn.roundValue(null, 2);
+      expect(str).to.be(null);
+    });
+  });
 
 
   describe('calculateInterval', function() {
   describe('calculateInterval', function() {
     it('1h 100 resultion', function() {
     it('1h 100 resultion', function() {