Skip to content

Commit fbe4273

Browse files
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
1 parent 23316cf commit fbe4273

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

API.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ Customizing the grid
657657
markings: array of markings or (fn: axes -> array of markings)
658658
borderWidth: number
659659
borderColor: color or null
660+
minBorderMargin: number or null
660661
clickable: boolean
661662
hoverable: boolean
662663
autoHighlight: boolean
@@ -678,9 +679,14 @@ above the data or below (below is default).
678679
line, and "axisMargin" is the space in pixels between axes when there
679680
are two next to each other. Note that you can style the tick labels
680681
with CSS, e.g. to change the color. They have class "tickLabel".
682+
681683
"borderWidth" is the width of the border around the plot. Set it to 0
682684
to disable the border. You can also set "borderColor" if you want the
683685
border to have a different color than the grid lines.
686+
"minBorderMargin" controls the default minimum margin around the
687+
border - it's used to make sure that points aren't accidentally
688+
clipped by the canvas edge so by default the value is computed from
689+
the point radius.
684690

685691
"markings" is used to draw simple lines and rectangular areas in the
686692
background of the plot. You can either specify an array of ranges on

NEWS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ Changes:
9292
isn't shown.
9393
- New attribute $.plot.version with the Flot version as a string.
9494
- The version comment is now included in the minified jquery.flot.min.js.
95+
- New options.grid.minBorderMargin for adjusting the minimum margin
96+
provided around the border (based on patch by corani, issue 188).
9597

9698
- New hooks: drawSeries
9799

jquery.flot.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
labelMargin: 5, // in pixels
122122
axisMargin: 8, // in pixels
123123
borderWidth: 2, // in pixels
124+
minBorderMargin: null, // in pixels, null means taken from points radius
124125
markings: null, // array of ranges or fn: axes -> array of ranges
125126
markingsColor: "#f4f4f4",
126127
markingsLineWidth: 2,
@@ -949,13 +950,16 @@
949950

950951
// make sure we've got enough space for things that
951952
// might stick out
952-
var maxOutset = 0;
953-
for (i = 0; i < series.length; ++i)
954-
maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
955-
953+
var minMargin = options.grid.minBorderMargin;
954+
if (minMargin == null) {
955+
minMargin = 0;
956+
for (i = 0; i < series.length; ++i)
957+
minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2);
958+
}
959+
956960
for (var a in plotOffset) {
957961
plotOffset[a] += options.grid.borderWidth;
958-
plotOffset[a] = Math.max(maxOutset, plotOffset[a]);
962+
plotOffset[a] = Math.max(minMargin, plotOffset[a]);
959963
}
960964
}
961965

0 commit comments

Comments
 (0)