Bug fixes for flexible Y-Min and Y-Max settings (#6066)

* fix(flexible_y-min/max): fixed negative values support and added tests for this.

* fix(flexible_y-min/max): fixed issue with Y-Min and Y-Max values stored as numbers.
	Issue: panels with configured Y-Min and Y-Max don't display anything
		   after upgrade.
This commit is contained in:
Alexander Zobnin 2016-09-20 12:23:31 +03:00 committed by Torkel Ödegaard
parent d2fb660557
commit e926b01185
2 changed files with 49 additions and 1 deletions

View File

@ -354,7 +354,8 @@ function (angular, $, moment, _, kbn, GraphTooltip, thresholdManExports) {
function parseThresholdExpr(expr) {
var match, operator, value, precision;
match = expr.match(/\s*([<=>~]*)\W*(\d+(\.\d+)?)/);
expr = String(expr);
match = expr.match(/\s*([<=>~]*)\s*(\-?\d+(\.\d+)?)/);
if (match) {
operator = match[1];
value = parseFloat(match[2]);

View File

@ -312,5 +312,52 @@ describe('grafanaGraph', function() {
expect(ctx.plotOptions.yaxes[0].max).to.be(0);
});
});
describe('and negative values used', function() {
ctx.setup(function(ctrl, data) {
ctrl.panel.yaxes[0].min = '-10';
ctrl.panel.yaxes[0].max = '-13.14';
data[0] = new TimeSeries({
datapoints: [[120,10],[160,20]],
alias: 'series1',
});
});
it('should set min and max to negative', function() {
expect(ctx.plotOptions.yaxes[0].min).to.be(-10);
expect(ctx.plotOptions.yaxes[0].max).to.be(-13.14);
});
});
});
graphScenario('when using Y-Min and Y-Max settings stored as number', function(ctx) {
describe('and Y-Min is 0 and Y-Max is 100', function() {
ctx.setup(function(ctrl, data) {
ctrl.panel.yaxes[0].min = 0;
ctrl.panel.yaxes[0].max = 100;
data[0] = new TimeSeries({
datapoints: [[120,10],[160,20]],
alias: 'series1',
});
});
it('should set min to 0 and max to 100', function() {
expect(ctx.plotOptions.yaxes[0].min).to.be(0);
expect(ctx.plotOptions.yaxes[0].max).to.be(100);
});
});
describe('and Y-Min is -100 and Y-Max is -10.5', function() {
ctx.setup(function(ctrl, data) {
ctrl.panel.yaxes[0].min = -100;
ctrl.panel.yaxes[0].max = -10.5;
data[0] = new TimeSeries({
datapoints: [[120,10],[160,20]],
alias: 'series1',
});
});
it('should set min to -100 and max to -10.5', function() {
expect(ctx.plotOptions.yaxes[0].min).to.be(-100);
expect(ctx.plotOptions.yaxes[0].max).to.be(-10.5);
});
});
});
});