diff --git a/CHANGELOG.md b/CHANGELOG.md index 70bd5222a91..58b08eacb4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [Issue #1126](https://github.com/grafana/grafana/issues/1126). InfluxDB: Support more than 10 series name segments when using alias ``$number`` patterns **Fixes** +- [Issue #1251](https://github.com/grafana/grafana/issues/1251). Graph: Fix for y axis and scaled units (GiB etc) caused rounding, for example 400 GiB instead of 378 GiB - [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled - [Issue #1207](https://github.com/grafana/grafana/issues/1207). Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index ecef4bd164e..aedfbb90f17 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -339,7 +339,7 @@ function($, _, moment) { return ""; } - var factor = decimals ? Math.pow(10, decimals) : 1; + var factor = decimals ? Math.pow(10, Math.max(0, decimals)) : 1; var formatted = String(Math.round(value * factor) / factor); // if exponent return directly diff --git a/src/test/specs/kbn-format-specs.js b/src/test/specs/kbn-format-specs.js index e92e6d0ceec..785d9376411 100644 --- a/src/test/specs/kbn-format-specs.js +++ b/src/test/specs/kbn-format-specs.js @@ -29,6 +29,13 @@ define([ describeValueFormat('ns', 25, 1, 0, '25 ns'); describeValueFormat('ns', 2558, 50, 0, '2.56 µs'); + describe('kbn.toFixed and negative decimals', function() { + it('should treat as zero decimals', function() { + var str = kbn.toFixed(186.123, -2); + expect(str).to.be('186'); + }); + }); + describe('calculateInterval', function() { it('1h 100 resultion', function() { var range = { from: kbn.parseDate('now-1h'), to: kbn.parseDate('now') };