mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixes #189, correction to ms axis formater, now formats days correctly
This commit is contained in:
parent
49492e7bca
commit
305d5c5aa9
@ -597,18 +597,12 @@ function($, _, moment) {
|
||||
else if (size < 86400000) {
|
||||
return (size / 3600000).toFixed(decimals) + " hour";
|
||||
}
|
||||
// Less than one week, devide in days
|
||||
else if (size < 604800000) {
|
||||
// Less than one year, devide in days
|
||||
else if (size < 31536000000) {
|
||||
return (size / 86400000).toFixed(decimals) + " day";
|
||||
}
|
||||
// Less than one month, devide in weeks
|
||||
else if (size < 2.62974e9) {
|
||||
return (size / 604800000).toFixed(decimals) + " week";
|
||||
}
|
||||
// Less than one year, devide in weeks
|
||||
else if (size < 3.15569e10) {
|
||||
return (size / 2.62974e9).toFixed(decimals) + " year";
|
||||
}
|
||||
|
||||
return (size / 31536000000).toFixed(decimals) + " year";
|
||||
};
|
||||
|
||||
kbn.microsFormat = function(size, decimals) {
|
||||
|
23
src/test/specs/kbn-format-specs.js
Normal file
23
src/test/specs/kbn-format-specs.js
Normal file
@ -0,0 +1,23 @@
|
||||
define([
|
||||
'kbn'
|
||||
], function(kbn) {
|
||||
|
||||
describe('millisecond formating', function() {
|
||||
|
||||
it('should translate 4378634603 as 1.67 years', function() {
|
||||
var str = kbn.msFormat(4378634603, 2);
|
||||
expect(str).to.be('50.68 day');
|
||||
});
|
||||
|
||||
it('should translate 3654454 as 1.02 hour', function() {
|
||||
var str = kbn.msFormat(3654454, 2);
|
||||
expect(str).to.be('1.02 hour');
|
||||
});
|
||||
|
||||
it('should translate 365445 as 6.09 min', function() {
|
||||
var str = kbn.msFormat(365445, 2);
|
||||
expect(str).to.be('6.09 min');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@ -115,6 +115,7 @@ require([
|
||||
'specs/parser-specs',
|
||||
'specs/gfunc-specs',
|
||||
'specs/filterSrv-specs',
|
||||
'specs/kbn-format-specs',
|
||||
], function () {
|
||||
window.__karma__.start();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user