Просмотр исходного кода

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

Torkel Ödegaard 11 лет назад
Родитель
Сommit
27c536b1a1
2 измененных файлов с 5 добавлено и 1 удалено
  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);
 
     // if exponent return directly
-    if (formatted.indexOf('e') !== -1) {
+    if (formatted.indexOf('e') !== -1 || value === 0) {
       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 });
       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() {