From 436abc2f2ebb9f45d0de2e8148ef44d4a4a2c945 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Mon, 10 Mar 2008 09:33:53 +0000 Subject: [PATCH] Really fix spacing bug git-svn-id: https://flot.googlecode.com/svn/trunk@61 1e0a6537-2640-0410-bfb7-f154510ff394 --- NEWS.txt | 6 ++++++ jquery.flot.js | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index d635829..56646c3 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,3 +1,9 @@ +Flot x.x +-------- + +Fixed a bug in calculating spacing around the plot (reported by timothytoe). + + Flot 0.4 -------- diff --git a/jquery.flot.js b/jquery.flot.js index df5095f..75c84bf 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -695,7 +695,7 @@ dummyDiv.remove(); } - var maxOutset = options.grid.borderWidth; + var maxOutset = options.grid.borderWidth / 2; if (options.points.show) maxOutset = Math.max(maxOutset, options.points.radius + options.points.lineWidth/2); for (i = 0; i < series.length; ++i) { @@ -704,8 +704,9 @@ } plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = maxOutset; - - plotOffset.left += yLabelMaxWidth + options.grid.labelMargin; + + if (yLabelMaxWidth > 0) + plotOffset.left += yLabelMaxWidth + options.grid.labelMargin; plotWidth = canvasWidth - plotOffset.left - plotOffset.right; // set width for labels; to avoid measuring the widths of @@ -730,7 +731,9 @@ dummyDiv.remove(); } - plotOffset.bottom += xLabelMaxHeight + options.grid.labelMargin; + if (xLabelMaxHeight > 0) + plotOffset.bottom += xLabelMaxHeight + options.grid.labelMargin; + plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top; hozScale = plotWidth / (xaxis.max - xaxis.min); vertScale = plotHeight / (yaxis.max - yaxis.min);