Commit 571d86e9 authored by David Schnur's avatar David Schnur

Restore 0.7's maximum width for x-axis labels.

Flot 0.7 calculated x-axis label dimensions by assigning each label a
fixed width, then measuring the height as determined by the browser.  A
side-effect of this technique is that x-axis label divs received a fixed
width.  The rewrite of the text system in 0.8 accidentally removed this
feature; this patch restores it.
parent e8ef7084
...@@ -1284,8 +1284,11 @@ Licensed under the MIT license. ...@@ -1284,8 +1284,11 @@ Licensed under the MIT license.
function measureTickLabels(axis) { function measureTickLabels(axis) {
var opts = axis.options, ticks = axis.ticks || [], var opts = axis.options,
axisw = opts.labelWidth || 0, axish = opts.labelHeight || 0, ticks = axis.ticks || [],
labelWidth = opts.labelWidth || 0,
labelHeight = opts.labelHeight || 0,
maxWidth = labelWidth || axis.direction == "x" ? Math.floor(surface.width / (ticks.length || 1)) : null;
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis", legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles, layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
font = opts.font || "flot-tick-label tickLabel"; font = opts.font || "flot-tick-label tickLabel";
...@@ -1297,16 +1300,14 @@ Licensed under the MIT license. ...@@ -1297,16 +1300,14 @@ Licensed under the MIT license.
if (!t.label) if (!t.label)
continue; continue;
var info = surface.getTextInfo(layer, t.label, font); var info = surface.getTextInfo(layer, t.label, font, null, maxWidth);
if (opts.labelWidth == null) labelWidth = Math.max(labelWidth, info.width);
axisw = Math.max(axisw, info.width); labelHeight = Math.max(labelHeight, info.height);
if (opts.labelHeight == null)
axish = Math.max(axish, info.height);
} }
axis.labelWidth = Math.ceil(axisw); axis.labelWidth = opts.labelWidth || labelWidth;
axis.labelHeight = Math.ceil(axish); axis.labelHeight = opts.labelHeight || labelHeight;
} }
function allocateAxisBoxFirstPhase(axis) { function allocateAxisBoxFirstPhase(axis) {
......
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