Commit 9c73b2fa by herver Committed by Torkel Ödegaard

Support data units for both IEC (Binary) and Metric (Decimal) variants (#5473)

parent 53f110c9
......@@ -374,13 +374,20 @@ function($, _, moment) {
kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency('€');
kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency('¥');
// Data
// Data (Binary)
kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix('b');
kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix('B');
kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix('B', 1);
kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix('B', 2);
kbn.valueFormats.gbytes = kbn.formatBuilders.binarySIPrefix('B', 3);
// Data (Decimal)
kbn.valueFormats.decbits = kbn.formatBuilders.decimalSIPrefix('b');
kbn.valueFormats.decbytes = kbn.formatBuilders.decimalSIPrefix('B');
kbn.valueFormats.deckbytes = kbn.formatBuilders.decimalSIPrefix('B', 1);
kbn.valueFormats.decmbytes = kbn.formatBuilders.decimalSIPrefix('B', 2);
kbn.valueFormats.decgbytes = kbn.formatBuilders.decimalSIPrefix('B', 3);
// Data Rate
kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix('pps');
kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
......@@ -637,13 +644,23 @@ function($, _, moment) {
]
},
{
text: 'data',
text: 'data (IEC)',
submenu: [
{text: 'bits', value: 'bits' },
{text: 'bytes', value: 'bytes' },
{text: 'kilobytes', value: 'kbytes'},
{text: 'megabytes', value: 'mbytes'},
{text: 'gigabytes', value: 'gbytes'},
{text: 'kibibytes', value: 'kbytes'},
{text: 'mebibytes', value: 'mbytes'},
{text: 'gibibytes', value: 'gbytes'},
]
},
{
text: 'data (Metric)',
submenu: [
{text: 'bits', value: 'decbits' },
{text: 'bytes', value: 'decbytes' },
{text: 'kilobytes', value: 'deckbytes'},
{text: 'megabytes', value: 'decmbytes'},
{text: 'gigabytes', value: 'decgbytes'},
]
},
{
......
......@@ -110,6 +110,13 @@ define([
});
});
describe('kbn deckbytes format when scaled decimals is null do not use it', function() {
it('should use specified decimals', function() {
var str = kbn.valueFormats['deckbytes'](10000000, 3, null);
expect(str).to.be('10.000 GB');
});
});
describe('kbn roundValue', function() {
it('should should handle null value', function() {
var str = kbn.roundValue(null, 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment