Commit 5ec525a4 by Markus Linnala

add bits format for Y-Axis

parent ed9e336c
...@@ -458,6 +458,53 @@ function($, _, moment) { ...@@ -458,6 +458,53 @@ function($, _, moment) {
return (size.toFixed(decimals) + ext); return (size.toFixed(decimals) + ext);
}; };
kbn.bitFormat = function(size, decimals) {
var ext, steps = 0;
if(_.isUndefined(decimals)) {
decimals = 2;
} else if (decimals === 0) {
decimals = undefined;
}
while (Math.abs(size) >= 1024) {
steps++;
size /= 1024;
}
switch (steps) {
case 0:
ext = " b";
break;
case 1:
ext = " Kb";
break;
case 2:
ext = " Mb";
break;
case 3:
ext = " Gb";
break;
case 4:
ext = " Tb";
break;
case 5:
ext = " Pb";
break;
case 6:
ext = " Eb";
break;
case 7:
ext = " Zb";
break;
case 8:
ext = " Yb";
break;
}
return (size.toFixed(decimals) + ext);
};
kbn.shortFormat = function(size, decimals) { kbn.shortFormat = function(size, decimals) {
var ext, steps = 0; var ext, steps = 0;
...@@ -515,6 +562,10 @@ function($, _, moment) { ...@@ -515,6 +562,10 @@ function($, _, moment) {
return function(val) { return function(val) {
return kbn.byteFormat(val, decimals); return kbn.byteFormat(val, decimals);
}; };
case 'bits':
return function(val) {
return kbn.bitFormat(val, decimals);
};
case 'ms': case 'ms':
return function(val) { return function(val) {
return kbn.msFormat(val, decimals); return kbn.msFormat(val, decimals);
......
...@@ -336,6 +336,9 @@ function (angular, $, kbn, moment, _) { ...@@ -336,6 +336,9 @@ function (angular, $, kbn, moment, _) {
case 'bytes': case 'bytes':
url += '&yUnitSystem=binary'; url += '&yUnitSystem=binary';
break; break;
case 'bits':
url += '&yUnitSystem=binary';
break;
case 'short': case 'short':
url += '&yUnitSystem=si'; url += '&yUnitSystem=si';
break; break;
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Left Y Format <tip>Y-axis formatting</tip></label> <label class="small">Left Y Format <tip>Y-axis formatting</tip></label>
<select class="input-small" ng-model="panel.y_formats[0]" ng-options="f for f in ['none','short','bytes', 'ms', 'µs']" ng-change="render()"></select> <select class="input-small" ng-model="panel.y_formats[0]" ng-options="f for f in ['none','short','bytes', 'bits', 'ms', 'µs']" ng-change="render()"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Right Y Format <tip>Y-axis formatting</tip></label> <label class="small">Right Y Format <tip>Y-axis formatting</tip></label>
<select class="input-small" ng-model="panel.y_formats[1]" ng-options="f for f in ['none','short','bytes', 'ms', 'µs']" ng-change="render()"></select> <select class="input-small" ng-model="panel.y_formats[1]" ng-options="f for f in ['none','short','bytes', 'bits', 'ms', 'µs']" ng-change="render()"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
......
...@@ -84,7 +84,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -84,7 +84,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
*/ */
scale : 1, scale : 1,
/** @scratch /panels/histogram/3 /** @scratch /panels/histogram/3
* y_formats :: 'none','bytes','short', 'ms' * y_formats :: 'none','bytes','bits','short', 'ms'
*/ */
y_formats : ['short', 'short'], y_formats : ['short', 'short'],
/** @scratch /panels/histogram/5 /** @scratch /panels/histogram/5
......
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