Commit 07598593 authored by David Schnur's avatar David Schnur

Added a grid.margin option

parent 4ee1e04e
......@@ -667,6 +667,7 @@ Customizing the grid
aboveData: boolean
color: color
backgroundColor: color/gradient or null
margin: number or margin object
labelMargin: number
axisMargin: number
markings: array of markings or (fn: axes -> array of markings)
......@@ -694,6 +695,17 @@ You can turn off the whole grid including tick labels by setting
"show" to false. "aboveData" determines whether the grid is drawn
above the data or below (below is default).
"margin" is the space in pixels between the canvas edge and the grid,
which can be either a number or an object with individual margins for
each side, in the form:
margin: {
top: top margin in pixels
left: left margin in pixels
bottom: bottom margin in pixels
right: right margin in pixels
}
"labelMargin" is the space in pixels between tick labels and axis
line, and "axisMargin" is the space in pixels between axes when there
are two next to each other.
......
......@@ -30,6 +30,11 @@ Changes:
- Tick generators now get the whole axis rather than just min/max.
- Added processOffset and drawBackground hooks (suggested in issue 639).
- Added a grid "margin" option to set the space between the canvas edge
and the grid.
Bug fixes
- Fix problem with null values and pie plugin (patch by gcruxifix,
......
......@@ -122,6 +122,7 @@
backgroundColor: null, // null for transparent, else color
borderColor: null, // set if different from the grid color
tickColor: null, // color for the ticks, e.g. "rgba(0,0,0,0.15)"
margin: 0, // distance from the canvas edge to the grid
labelMargin: 5, // in pixels
axisMargin: 8, // in pixels
borderWidth: 2, // in pixels
......@@ -1023,12 +1024,20 @@
function setupGrid() {
var i, axes = allAxes(), showGrid = options.grid.show;
// init plot offset
for (var a in plotOffset)
plotOffset[a] = showGrid ? options.grid.borderWidth : 0;
// Initialize the plot's offset from the edge of the canvas
for (var a in plotOffset) {
var margin = options.grid.margin || 0;
plotOffset[a] = typeof margin == "number" ? margin : margin[a] || 0;
}
executeHooks(hooks.processOffset, [plotOffset]);
// If the grid is visible, add its border width to the offset
for (var a in plotOffset)
plotOffset[a] += showGrid ? options.grid.borderWidth : 0;
// init axes
$.each(axes, function (_, axis) {
axis.show = axis.options.show;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment