From 1158d06325bf9f19847cad65a371585c8b37d34a Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Thu, 6 Aug 2009 09:55:16 +0000 Subject: [PATCH] Fix a bug with axis range margins not being set in the same way (patch by Paul Kienzle), and fix snap to ticks so it works correctly with max ticks git-svn-id: https://flot.googlecode.com/svn/trunk@195 1e0a6537-2640-0410-bfb7-f154510ff394 --- jquery.flot.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 5f1ebe7..fec4b2b 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -693,9 +693,10 @@ function setRange(axis, axisOptions) { var min = +(axisOptions.min != null ? axisOptions.min : axis.datamin), - max = +(axisOptions.max != null ? axisOptions.max : axis.datamax); + max = +(axisOptions.max != null ? axisOptions.max : axis.datamax), + delta = max - min; - if (max - min == 0.0) { + if (delta == 0.0) { // degenerate case var widen = max == 0 ? 1 : 0.01; @@ -711,14 +712,14 @@ var margin = axisOptions.autoscaleMargin; if (margin != null) { if (axisOptions.min == null) { - min -= (max - min) * margin; + min -= delta * margin; // make sure we don't go below zero if all values // are positive if (min < 0 && axis.datamin != null && axis.datamin >= 0) min = 0; } if (axisOptions.max == null) { - max += (max - min) * margin; + max += delta * margin; if (max > 0 && axis.datamax != null && axis.datamax <= 0) max = 0; } @@ -1009,7 +1010,7 @@ if (axisOptions.min == null) axis.min = Math.min(axis.min, axis.ticks[0].v); if (axisOptions.max == null && axis.ticks.length > 1) - axis.max = Math.min(axis.max, axis.ticks[axis.ticks.length - 1].v); + axis.max = Math.max(axis.max, axis.ticks[axis.ticks.length - 1].v); } }