added y format for right y axis
This commit is contained in:
@@ -98,6 +98,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
* y_format:: 'none','bytes','short '
|
||||
*/
|
||||
y_format : 'none',
|
||||
y2_format : 'none',
|
||||
/** @scratch /panels/histogram/5
|
||||
* grid object:: Min and max y-axis values
|
||||
* grid.min::: Minimum y-axis value
|
||||
@@ -583,14 +584,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
},
|
||||
shadowSize: 1
|
||||
},
|
||||
yaxes: [
|
||||
{
|
||||
position: 'left',
|
||||
show: scope.panel['y-axis'],
|
||||
min: scope.panel.grid.min,
|
||||
max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.max
|
||||
}
|
||||
],
|
||||
yaxes: [],
|
||||
xaxis: {
|
||||
timezone: scope.panel.timezone,
|
||||
show: scope.panel['x-axis'],
|
||||
@@ -609,16 +603,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
}
|
||||
};
|
||||
|
||||
if(scope.panel.y_format === 'bytes') {
|
||||
options.yaxes[0].mode = "byte";
|
||||
}
|
||||
|
||||
if(scope.panel.y_format === 'short') {
|
||||
options.yaxes[0].tickFormatter = function(val) {
|
||||
return kbn.shortFormat(val,0);
|
||||
};
|
||||
}
|
||||
|
||||
if(scope.panel.annotate.enable) {
|
||||
options.events = {
|
||||
levels: 1,
|
||||
@@ -659,17 +643,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
var _d = data[i].time_series.getFlotPairs(required_times, scope.panel.nullPointMode);
|
||||
data[i].yaxis = data[i].info.yaxis;
|
||||
data[i].data = _d;
|
||||
|
||||
if (options.yaxes.length === 1 && data[i].yaxis === 2) {
|
||||
options.yaxes.push({
|
||||
position: 'right',
|
||||
show: scope.panel['y-axis'],
|
||||
min: scope.panel.grid.min,
|
||||
max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.max
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
configureAxisOptions(data, options);
|
||||
|
||||
plot = $.plot(elem, data, options);
|
||||
|
||||
if (scope.panel.leftYAxisLabel) {
|
||||
@@ -684,6 +661,38 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
}
|
||||
}
|
||||
|
||||
function configureAxisOptions(data, options)
|
||||
{
|
||||
var defaults = {
|
||||
position: 'left',
|
||||
show: scope.panel['y-axis'],
|
||||
min: scope.panel.grid.min,
|
||||
max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.max
|
||||
};
|
||||
|
||||
options.yaxes.push(defaults);
|
||||
|
||||
if (_.findWhere(data, {yaxis: 2})) {
|
||||
var secondY = _.clone(defaults);
|
||||
secondY.position = 'right';
|
||||
options.yaxes.push(secondY);
|
||||
configureAxisMode(options.yaxes[1], scope.panel.y2_format);
|
||||
}
|
||||
|
||||
configureAxisMode(options.yaxes[0], scope.panel.y_format);
|
||||
}
|
||||
|
||||
function configureAxisMode(axis, format) {
|
||||
if (format === 'bytes') {
|
||||
axis.mode = "byte";
|
||||
}
|
||||
if (format === 'short') {
|
||||
axis.tickFormatter = function(val) {
|
||||
return kbn.shortFormat(val,0);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function time_format(interval) {
|
||||
var _int = kbn.interval_to_seconds(interval);
|
||||
if(_int >= 2628000) {
|
||||
|
||||
Reference in New Issue
Block a user