Commit 7f63b070 authored by David Schnur's avatar David Schnur

Work-around for full-width plots.

Introduces an unofficial work-around for the behavior introduced in
0.8.0, where we reserve extra space for the first and last tick labels.
 This makes it impossible for plots to span the full width of their
container.

This work-around overloads the reserveSpace option, which normally only
applies when show = false.  Now, if show = true and reserveSpace =
false, we skip the step that allocates extra space for labels.

We’ll introduce a proper solution in 0.9, but this should provide a way
for users to move forward in the meantime.
parent 27883ac9
...@@ -1446,7 +1446,7 @@ Licensed under the MIT license. ...@@ -1446,7 +1446,7 @@ Licensed under the MIT license.
// Determine the axis's position in its direction and on its side // Determine the axis's position in its direction and on its side
$.each(isXAxis ? xaxes : yaxes, function(i, a) { $.each(isXAxis ? xaxes : yaxes, function(i, a) {
if (a && a.reserveSpace) { if (a && (a.show || a.reserveSpace)) {
if (a === axis) { if (a === axis) {
found = true; found = true;
} else if (a.options.position === pos) { } else if (a.options.position === pos) {
...@@ -1589,20 +1589,18 @@ Licensed under the MIT license. ...@@ -1589,20 +1589,18 @@ Licensed under the MIT license.
} }
} }
// init axes
$.each(axes, function (_, axis) { $.each(axes, function (_, axis) {
axis.show = axis.options.show; var axisOpts = axis.options;
if (axis.show == null) axis.show = axisOpts.show == null ? axis.used : axisOpts.show;
axis.show = axis.used; // by default an axis is visible if it's got data axis.reserveSpace = axisOpts.reserveSpace == null ? axis.show : axisOpts.reserveSpace;
axis.reserveSpace = axis.show || axis.options.reserveSpace;
setRange(axis); setRange(axis);
}); });
if (showGrid) { if (showGrid) {
var allocatedAxes = $.grep(axes, function (axis) { return axis.reserveSpace; }); var allocatedAxes = $.grep(axes, function (axis) {
return axis.show || axis.reserveSpace;
});
$.each(allocatedAxes, function (_, axis) { $.each(allocatedAxes, function (_, axis) {
// make the ticks // make the ticks
......
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