Commit d973ba22 authored by David Schnur's avatar David Schnur

Merge pull request #1198 from dnschnur/axis-grid-fix

Distinguish between the first and innermost axis.
parents 7fa063e9 edac9e0e
...@@ -1400,37 +1400,50 @@ Licensed under the MIT license. ...@@ -1400,37 +1400,50 @@ Licensed under the MIT license.
var lw = axis.labelWidth, var lw = axis.labelWidth,
lh = axis.labelHeight, lh = axis.labelHeight,
pos = axis.options.position, pos = axis.options.position,
isXAxis = axis.direction === "x",
tickLength = axis.options.tickLength, tickLength = axis.options.tickLength,
axisMargin = options.grid.axisMargin, axisMargin = options.grid.axisMargin,
padding = options.grid.labelMargin, padding = options.grid.labelMargin,
all = axis.direction == "x" ? xaxes : yaxes, innermost = true,
index, innermost; outermost = true,
first = true,
// determine axis margin found = false;
var samePosition = $.grep(all, function (a) {
return a && a.options.position == pos && a.reserveSpace; // Determine the axis's position in its direction and on its side
$.each(isXAxis ? xaxes : yaxes, function(i, a) {
if (a && a.reserveSpace) {
if (a === axis) {
found = true;
} else if (a.options.position === pos) {
if (found) {
outermost = false;
} else {
innermost = false;
}
}
if (!found) {
first = false;
}
}
}); });
if ($.inArray(axis, samePosition) == samePosition.length - 1)
axisMargin = 0; // outermost
// Determine whether the axis is the first (innermost) on its side // The outermost axis on each side has no margin
innermost = $.inArray(axis, samePosition) == 0; if (outermost) {
axisMargin = 0;
}
// determine tick length - if we're innermost, we can use "full" // The ticks for the first axis in each direction stretch across
if (tickLength == null) { if (tickLength == null) {
if (innermost) tickLength = first ? "full" : 5;
tickLength = "full";
else
tickLength = 5;
} }
if (!isNaN(+tickLength)) if (!isNaN(+tickLength))
padding += +tickLength; padding += +tickLength;
// compute box if (isXAxis) {
if (axis.direction == "x") {
lh += padding; lh += padding;
if (pos == "bottom") { if (pos == "bottom") {
......
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