Graph: fix for downscaling y-axis format, never downscale when value is zero, Fixes #826

This commit is contained in:
Torkel Ödegaard
2014-09-19 12:16:00 +02:00
parent a97bcc3ca7
commit 563dd898c1
3 changed files with 15 additions and 4 deletions
+4 -4
View File
@@ -567,8 +567,8 @@ function($, _, moment) {
kbn.msFormat = function(size, decimals) {
// Less than 1 milli, downscale to micro
if (Math.abs(size) < 1) {
return kbn.microsFormat(size * 1000,decimals);
if (size !== 0 && Math.abs(size) < 1) {
return kbn.microsFormat(size * 1000, decimals);
}
else if (Math.abs(size) < 1000) {
return size.toFixed(decimals) + " ms";
@@ -595,7 +595,7 @@ function($, _, moment) {
kbn.sFormat = function(size, decimals) {
// Less than 1 sec, downscale to milli
if (Math.abs(size) < 1) {
if (size !== 0 && Math.abs(size) < 1) {
return kbn.msFormat(size * 1000, decimals);
}
// Less than 10 min, use seconds
@@ -624,7 +624,7 @@ function($, _, moment) {
kbn.microsFormat = function(size, decimals) {
// Less than 1 micro, downscale to nano
if (Math.abs(size) < 1) {
if (size !== 0 && Math.abs(size) < 1) {
return kbn.nanosFormat(size * 1000, decimals);
}
else if (Math.abs(size) < 1000) {
+5
View File
@@ -110,6 +110,11 @@ function (angular, $, kbn, moment, _) {
// Populate element
var options = {
hooks: {
drawSeries: [function() {
console.log('drawSeries', arguments);
}]
},
legend: { show: false },
series: {
stackpercent: panel.stack ? panel.percentage : false,
+6
View File
@@ -15,6 +15,12 @@ define([
expect(str).to.be('1.02 hour');
});
it('should not downscale when value is zero', function() {
var str = kbn.msFormat(0, 2);
expect(str).to.be('0.00 ms');
});
it('should translate 365445 as 6.09 min', function() {
var str = kbn.msFormat(365445, 2);
expect(str).to.be('6.09 min');