Commit 989d703d by Ian Clark

Adding bps unit type for network gear

parent fd8561ac
...@@ -396,6 +396,53 @@ function($, _, moment) { ...@@ -396,6 +396,53 @@ function($, _, moment) {
return (size.toFixed(decimals) + ext); return (size.toFixed(decimals) + ext);
}; };
kbn.bpsFormat = function(size, decimals) {
var ext, steps = 0;
if(_.isUndefined(decimals)) {
decimals = 2;
} else if (decimals === 0) {
decimals = undefined;
}
while (Math.abs(size) >= 1000) {
steps++;
size /= 1000;
}
switch (steps) {
case 0:
ext = " bps";
break;
case 1:
ext = " Kbps";
break;
case 2:
ext = " Mbps";
break;
case 3:
ext = " Gbps";
break;
case 4:
ext = " Tbps";
break;
case 5:
ext = " Pbps";
break;
case 6:
ext = " Ebps";
break;
case 7:
ext = " Zbps";
break;
case 8:
ext = " Ybps";
break;
}
return (size.toFixed(decimals) + ext);
};
kbn.shortFormat = function(size, decimals) { kbn.shortFormat = function(size, decimals) {
var ext, steps = 0; var ext, steps = 0;
...@@ -457,6 +504,10 @@ function($, _, moment) { ...@@ -457,6 +504,10 @@ function($, _, moment) {
return function(val) { return function(val) {
return kbn.bitFormat(val, decimals); return kbn.bitFormat(val, decimals);
}; };
case 'bps':
return function(val) {
return kbn.bpsFormat(val, decimals);
};
case 's': case 's':
return function(val) { return function(val) {
return kbn.sFormat(val, decimals); return kbn.sFormat(val, decimals);
......
...@@ -367,6 +367,9 @@ function (angular, $, kbn, moment, _) { ...@@ -367,6 +367,9 @@ function (angular, $, kbn, moment, _) {
case 'bits': case 'bits':
url += '&yUnitSystem=binary'; url += '&yUnitSystem=binary';
break; break;
case 'bps':
url += '&yUnitSystem=si';
break;
case 'short': case 'short':
url += '&yUnitSystem=si'; url += '&yUnitSystem=si';
break; break;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<h5>Left Y Axis</h5> <h5>Left Y Axis</h5>
<div class="editor-option"> <div class="editor-option">
<label class="small">Format <tip>Y-axis formatting</tip></label> <label class="small">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', 'bits', 's', 'ms', 'µs', 'ns']" ng-change="render()"></select> <select class="input-small" ng-model="panel.y_formats[0]" ng-options="f for f in ['none','short','bytes', 'bits', 'bps', 's', 'ms', 'µs', 'ns']" ng-change="render()"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Min / <a ng-click="toggleGridMinMax('leftMin')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.leftMin)"></i></a></label> <label class="small">Min / <a ng-click="toggleGridMinMax('leftMin')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.leftMin)"></i></a></label>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<h5>Right Y Axis</h5> <h5>Right Y Axis</h5>
<div class="editor-option"> <div class="editor-option">
<label class="small">Format <tip>Y-axis formatting</tip></label> <label class="small">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', 'bits', 's', 'ms', 'µs', 'ns']" ng-change="render()"></select> <select class="input-small" ng-model="panel.y_formats[1]" ng-options="f for f in ['none','short','bytes', 'bits', 'bps', 's', 'ms', 'µs', 'ns']" ng-change="render()"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Min / <a ng-click="toggleGridMinMax('rightMin')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.rightMin)"></i></a></label> <label class="small">Min / <a ng-click="toggleGridMinMax('rightMin')">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.rightMin)"></i></a></label>
......
...@@ -86,7 +86,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -86,7 +86,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
*/ */
scale : 1, scale : 1,
/** @scratch /panels/histogram/3 /** @scratch /panels/histogram/3
* y_formats :: 'none','bytes','bits','short', 's', 'ms' * y_formats :: 'none','bytes','bits','bps','short', 's', '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