diff --git a/NEWS.txt b/NEWS.txt index 6c153d0..87655f3 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -2,7 +2,9 @@ Flot 0.x -------- Fixed two corner-case bugs when drawing filled curves (report and -analysis by Joshua Varner). +analysis by Joshua Varner). Fix auto-adjustment code when setting min +to 0 for an axis where the dataset is completely flat on that axis +(report by chovy). Flot 0.5 diff --git a/jquery.flot.js b/jquery.flot.js index 49ab308..dfb3e56 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -375,14 +375,14 @@ if (max - min == 0.0) { // degenerate case - var widen; - if (max == 0.0) - widen = 1.0; - else - widen = 0.01; + var widen = max == 0 ? 1 : 0.01; - min -= widen; - max += widen; + if (axisOptions.min == null) + min -= widen; + // alway widen max if we couldn't widen min to ensure we + // don't fall into min == max which doesn't work + if (axisOptions.max == null || axisOptions.min != null) + max += widen; } else { // consider autoscaling