diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 7f280cc99d6..3941715d9d9 100644 --- a/src/app/components/kbn.js +++ b/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; } diff --git a/src/test/specs/kbn-format-specs.js b/src/test/specs/kbn-format-specs.js index 7e80d1a91eb..0faa4728f2d 100644 --- a/src/test/specs/kbn-format-specs.js +++ b/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() {