From 72ad98a30fb5832fa5d2363f7cf8b692e7e292b5 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Thu, 9 Oct 2008 11:26:04 +0000 Subject: [PATCH] Fixed corner-case bug with axis-autoadjustment for flat datasets git-svn-id: https://flot.googlecode.com/svn/trunk@97 1e0a6537-2640-0410-bfb7-f154510ff394 --- NEWS.txt | 4 +++- jquery.flot.js | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) 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