Commit 799fd777 by Torkel Ödegaard

added y format for right y axis

parent 85578f01
...@@ -98,6 +98,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -98,6 +98,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
* y_format:: 'none','bytes','short ' * y_format:: 'none','bytes','short '
*/ */
y_format : 'none', y_format : 'none',
y2_format : 'none',
/** @scratch /panels/histogram/5 /** @scratch /panels/histogram/5
* grid object:: Min and max y-axis values * grid object:: Min and max y-axis values
* grid.min::: Minimum y-axis value * grid.min::: Minimum y-axis value
...@@ -583,14 +584,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -583,14 +584,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}, },
shadowSize: 1 shadowSize: 1
}, },
yaxes: [ 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
}
],
xaxis: { xaxis: {
timezone: scope.panel.timezone, timezone: scope.panel.timezone,
show: scope.panel['x-axis'], show: scope.panel['x-axis'],
...@@ -609,16 +603,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -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) { if(scope.panel.annotate.enable) {
options.events = { options.events = {
levels: 1, levels: 1,
...@@ -659,17 +643,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -659,17 +643,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
var _d = data[i].time_series.getFlotPairs(required_times, scope.panel.nullPointMode); var _d = data[i].time_series.getFlotPairs(required_times, scope.panel.nullPointMode);
data[i].yaxis = data[i].info.yaxis; data[i].yaxis = data[i].info.yaxis;
data[i].data = _d; 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); plot = $.plot(elem, data, options);
if (scope.panel.leftYAxisLabel) { if (scope.panel.leftYAxisLabel) {
...@@ -684,6 +661,38 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -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) { function time_format(interval) {
var _int = kbn.interval_to_seconds(interval); var _int = kbn.interval_to_seconds(interval);
if(_int >= 2628000) { if(_int >= 2628000) {
......
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