fix(graph): fix for when data min/max delta is zero and negative and grid y min/max is auto, fixes #6980

This commit is contained in:
Torkel Ödegaard
2016-12-19 09:30:52 +01:00
parent 3be77ad293
commit 090db9401c
+7 -5
View File
@@ -1663,14 +1663,16 @@ Licensed under the MIT license.
// Grafana fix: wide Y min and max using increased wideFactor // Grafana fix: wide Y min and max using increased wideFactor
// when all series values are the same // when all series values are the same
var wideFactor = 0.25; var wideFactor = 0.25;
var widen = max == 0 ? 1 : max * wideFactor; var widen = Math.abs(max == 0 ? 1 : max * wideFactor);
if (opts.min == null) if (opts.min == null) {
min -= widen; min -= widen;
}
// always widen max if we couldn't widen min to ensure we // always widen max if we couldn't widen min to ensure we
// don't fall into min == max which doesn't work // don't fall into min == max which doesn't work
if (opts.max == null || opts.min != null) if (opts.max == null || opts.min != null) {
max += widen; max += widen;
}
} }
else { else {
// consider autoscaling // consider autoscaling