From fbe4273b6e87df27cf89f126357ce37d4b3e66f2 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Tue, 15 Mar 2011 18:34:35 +0000 Subject: [PATCH] New options.grid.minBorderMargin for adjusting the minimum margin provided around the border (based on patch by corani, issue 188) git-svn-id: https://flot.googlecode.com/svn/trunk@315 1e0a6537-2640-0410-bfb7-f154510ff394 --- API.txt | 6 ++++++ NEWS.txt | 2 ++ jquery.flot.js | 14 +++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/API.txt b/API.txt index ba38af0..20c968a 100644 --- a/API.txt +++ b/API.txt @@ -657,6 +657,7 @@ Customizing the grid markings: array of markings or (fn: axes -> array of markings) borderWidth: number borderColor: color or null + minBorderMargin: number or null clickable: boolean hoverable: boolean autoHighlight: boolean @@ -678,9 +679,14 @@ above the data or below (below is default). line, and "axisMargin" is the space in pixels between axes when there are two next to each other. Note that you can style the tick labels with CSS, e.g. to change the color. They have class "tickLabel". + "borderWidth" is the width of the border around the plot. Set it to 0 to disable the border. You can also set "borderColor" if you want the border to have a different color than the grid lines. +"minBorderMargin" controls the default minimum margin around the +border - it's used to make sure that points aren't accidentally +clipped by the canvas edge so by default the value is computed from +the point radius. "markings" is used to draw simple lines and rectangular areas in the background of the plot. You can either specify an array of ranges on diff --git a/NEWS.txt b/NEWS.txt index 5c123e2..d63fb1f 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -92,6 +92,8 @@ Changes: isn't shown. - New attribute $.plot.version with the Flot version as a string. - The version comment is now included in the minified jquery.flot.min.js. +- New options.grid.minBorderMargin for adjusting the minimum margin + provided around the border (based on patch by corani, issue 188). - New hooks: drawSeries diff --git a/jquery.flot.js b/jquery.flot.js index 7652d69..287f98e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -121,6 +121,7 @@ labelMargin: 5, // in pixels axisMargin: 8, // in pixels borderWidth: 2, // in pixels + minBorderMargin: null, // in pixels, null means taken from points radius markings: null, // array of ranges or fn: axes -> array of ranges markingsColor: "#f4f4f4", markingsLineWidth: 2, @@ -949,13 +950,16 @@ // make sure we've got enough space for things that // might stick out - var maxOutset = 0; - for (i = 0; i < series.length; ++i) - maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2)); - + var minMargin = options.grid.minBorderMargin; + if (minMargin == null) { + minMargin = 0; + for (i = 0; i < series.length; ++i) + minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2); + } + for (var a in plotOffset) { plotOffset[a] += options.grid.borderWidth; - plotOffset[a] = Math.max(maxOutset, plotOffset[a]); + plotOffset[a] = Math.max(minMargin, plotOffset[a]); } }