Quellcode durchsuchen

Small fix to 'none' axis formats and zero value when axis tickDecimals is high, Closes #707

Torkel Ödegaard vor 11 Jahren
Ursprung
Commit
27c536b1a1
2 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 1 1
      src/app/components/kbn.js
  2. 4 0
      src/test/specs/kbn-format-specs.js

+ 1 - 1
src/app/components/kbn.js

@@ -536,7 +536,7 @@ function($, _, moment) {
     var formatted = String(Math.round(value * factor) / factor);
     var formatted = String(Math.round(value * factor) / factor);
 
 
     // if exponent return directly
     // if exponent return directly
-    if (formatted.indexOf('e') !== -1) {
+    if (formatted.indexOf('e') !== -1 || value === 0) {
       return formatted;
       return formatted;
     }
     }
 
 

+ 4 - 0
src/test/specs/kbn-format-specs.js

@@ -27,6 +27,10 @@ define([
       var str = kbn.getFormatFunction('')(2.75e-10, { tickDecimals: 12 });
       var str = kbn.getFormatFunction('')(2.75e-10, { tickDecimals: 12 });
       expect(str).to.be('2.75e-10');
       expect(str).to.be('2.75e-10');
     });
     });
+    it('should format 0 correctly', function() {
+      var str = kbn.getFormatFunction('')(0.0, { tickDecimals: 12 });
+      expect(str).to.be('0');
+    });
   });
   });
 
 
   describe('none format tests', function() {
   describe('none format tests', function() {