singlestat: change threshold check in flot gauge

Fixes #5515. Flot gauge has its own threshold check that is different
from the threshold check in singlestat. This changes the flot check to
be exclusive (same as the singlestat check). E.g. if the threshold is
10, then the value 10 is over the threshold.
This commit is contained in:
Daniel Lee 2017-07-26 15:18:10 +02:00
parent cb8ecb2d5f
commit 7b768bca3f
3 changed files with 53 additions and 37 deletions

View File

@ -14,11 +14,27 @@ describe('grafanaSingleStat', function() {
expect(getColorForValue(data, 5)).to.be('green');
});
it('25 should return green', () => {
it('19.9 should return green', () => {
expect(getColorForValue(data, 19.9)).to.be('green');
});
it('20 should return yellow', () => {
expect(getColorForValue(data, 20)).to.be('yellow');
});
it('20.1 should return yellow', () => {
expect(getColorForValue(data, 20.1)).to.be('yellow');
});
it('25 should return yellow', () => {
expect(getColorForValue(data, 25)).to.be('yellow');
});
it('55 should return green', () => {
it('50 should return red', () => {
expect(getColorForValue(data, 50)).to.be('red');
});
it('55 should return red', () => {
expect(getColorForValue(data, 55)).to.be('red');
});
});

View File

@ -108,7 +108,7 @@ describe('SingleStatCtrl', function() {
});
});
singleStatScenario('When range to text mapping is specifiedfor first range', function(ctx) {
singleStatScenario('When range to text mapping is specified for first range', function(ctx) {
ctx.setup(function() {
ctx.data = [
{target: 'test.cpu1', datapoints: [[41,50]]}

View File

@ -371,7 +371,7 @@
for (var i = 0; i < gaugeOptionsi.threshold.values.length; i++) {
var threshold = gaugeOptionsi.threshold.values[i];
color = threshold.color;
if (data <= threshold.value) {
if (data < threshold.value) {
break;
}
}