mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Support data units for both IEC (Binary) and Metric (Decimal) variants (#5473)
This commit is contained in:
@@ -374,13 +374,20 @@ function($, _, moment) {
|
|||||||
kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency('€');
|
kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency('€');
|
||||||
kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency('¥');
|
kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency('¥');
|
||||||
|
|
||||||
// Data
|
// Data (Binary)
|
||||||
kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix('b');
|
kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix('b');
|
||||||
kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix('B');
|
kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix('B');
|
||||||
kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix('B', 1);
|
kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix('B', 1);
|
||||||
kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix('B', 2);
|
kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix('B', 2);
|
||||||
kbn.valueFormats.gbytes = kbn.formatBuilders.binarySIPrefix('B', 3);
|
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
|
// Data Rate
|
||||||
kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix('pps');
|
kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix('pps');
|
||||||
kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
|
kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
|
||||||
@@ -637,13 +644,23 @@ function($, _, moment) {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'data',
|
text: 'data (IEC)',
|
||||||
submenu: [
|
submenu: [
|
||||||
{text: 'bits', value: 'bits' },
|
{text: 'bits', value: 'bits' },
|
||||||
{text: 'bytes', value: 'bytes' },
|
{text: 'bytes', value: 'bytes' },
|
||||||
{text: 'kilobytes', value: 'kbytes'},
|
{text: 'kibibytes', value: 'kbytes'},
|
||||||
{text: 'megabytes', value: 'mbytes'},
|
{text: 'mebibytes', value: 'mbytes'},
|
||||||
{text: 'gigabytes', value: 'gbytes'},
|
{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() {
|
describe('kbn roundValue', function() {
|
||||||
it('should should handle null value', function() {
|
it('should should handle null value', function() {
|
||||||
var str = kbn.roundValue(null, 2);
|
var str = kbn.roundValue(null, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user