Commit cfe16e1e authored by David Schnur's avatar David Schnur

Rename labelWidth/Height to tickWidth/Height.

parent b079efca
...@@ -264,12 +264,11 @@ xaxis, yaxis: { ...@@ -264,12 +264,11 @@ xaxis, yaxis: {
tickFormatter: (fn: number, object -> string) or string tickFormatter: (fn: number, object -> string) or string
tickDecimals: null or number tickDecimals: null or number
labelWidth: null or number
labelHeight: null or number
reserveSpace: null or true
tickLength: null or number tickLength: null or number
tickWidth: null or number
tickHeight: null or number
reserveSpace: null or true
alignTicksWithAxis: null or number alignTicksWithAxis: null or number
} }
``` ```
......
...@@ -495,8 +495,8 @@ Licensed under the MIT license. ...@@ -495,8 +495,8 @@ Licensed under the MIT license.
autoscaleMargin: null, // margin in % to add if auto-setting min/max autoscaleMargin: null, // margin in % to add if auto-setting min/max
ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
tickFormatter: null, // fn: number -> string tickFormatter: null, // fn: number -> string
labelWidth: null, // size of tick labels in pixels tickWidth: null, // size of tick labels in pixels
labelHeight: null, tickHeight: null,
reserveSpace: null, // whether to reserve space even if axis isn't shown reserveSpace: null, // whether to reserve space even if axis isn't shown
tickLength: null, // size in pixels of ticks, or "full" for whole line tickLength: null, // size in pixels of ticks, or "full" for whole line
alignTicksWithAxis: null, // axis number or null for no sync alignTicksWithAxis: null, // axis number or null for no sync
...@@ -1370,9 +1370,10 @@ Licensed under the MIT license. ...@@ -1370,9 +1370,10 @@ Licensed under the MIT license.
var opts = axis.options, var opts = axis.options,
ticks = axis.ticks || [], ticks = axis.ticks || [],
labelWidth = opts.labelWidth || 0, // Label width & height are deprecated; remove in 1.0!
labelHeight = opts.labelHeight || 0, tickWidth = opts.tickWidth || opts.labelWidth || 0,
maxWidth = labelWidth || axis.direction === "x" ? Math.floor(surface.width / (ticks.length || 1)) : null, tickHeight = opts.tickHeight || opts.labelHeight || 0,
maxWidth = tickWidth || 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";
...@@ -1387,12 +1388,17 @@ Licensed under the MIT license. ...@@ -1387,12 +1388,17 @@ Licensed under the MIT license.
var info = surface.getTextInfo(layer, t.label, font, null, maxWidth); var info = surface.getTextInfo(layer, t.label, font, null, maxWidth);
labelWidth = Math.max(labelWidth, info.width); tickWidth = Math.max(tickWidth, info.width);
labelHeight = Math.max(labelHeight, info.height); tickHeight = Math.max(tickHeight, info.height);
} }
axis.labelWidth = opts.labelWidth || labelWidth; axis.tickWidth = opts.tickWidth || opts.labelWidth || tickWidth;
axis.labelHeight = opts.labelHeight || labelHeight; axis.tickHeight = opts.tickHeight || opts.labelHeight || tickHeight;
// Label width/height properties are deprecated; remove in 1.0!
axis.labelWidth = axis.tickWidth;
axis.labelHeight = axis.tickHeight;
} }
function allocateAxisBoxFirstPhase(axis) { function allocateAxisBoxFirstPhase(axis) {
...@@ -1402,8 +1408,8 @@ Licensed under the MIT license. ...@@ -1402,8 +1408,8 @@ Licensed under the MIT license.
// dimension per axis, the other dimension depends on the // dimension per axis, the other dimension depends on the
// other axes so will have to wait // other axes so will have to wait
var lw = axis.labelWidth, var lw = axis.tickWidth,
lh = axis.labelHeight, lh = axis.tickHeight,
pos = axis.options.position, pos = axis.options.position,
tickLength = axis.options.tickLength, tickLength = axis.options.tickLength,
axisMargin = options.grid.axisMargin, axisMargin = options.grid.axisMargin,
...@@ -1471,11 +1477,11 @@ Licensed under the MIT license. ...@@ -1471,11 +1477,11 @@ Licensed under the MIT license.
// now that all axis boxes have been placed in one // now that all axis boxes have been placed in one
// dimension, we can set the remaining dimension coordinates // dimension, we can set the remaining dimension coordinates
if (axis.direction === "x") { if (axis.direction === "x") {
axis.box.left = plotOffset.left - axis.labelWidth / 2; axis.box.left = plotOffset.left - axis.tickWidth / 2;
axis.box.width = surface.width - plotOffset.left - plotOffset.right + axis.labelWidth; axis.box.width = surface.width - plotOffset.left - plotOffset.right + axis.tickWidth;
} else { } else {
axis.box.top = plotOffset.top - axis.labelHeight / 2; axis.box.top = plotOffset.top - axis.tickHeight / 2;
axis.box.height = surface.height - plotOffset.bottom - plotOffset.top + axis.labelHeight; axis.box.height = surface.height - plotOffset.bottom - plotOffset.top + axis.tickHeight;
} }
} }
...@@ -1504,7 +1510,7 @@ Licensed under the MIT license. ...@@ -1504,7 +1510,7 @@ Licensed under the MIT license.
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function (_, axis) {
var dir = axis.direction; var dir = axis.direction;
if (axis.reserveSpace) { if (axis.reserveSpace) {
margins[dir] = Math.ceil(Math.max(margins[dir], (dir === "x" ? axis.labelWidth : axis.labelHeight) / 2)); margins[dir] = Math.ceil(Math.max(margins[dir], (dir === "x" ? axis.tickWidth : axis.tickHeight) / 2));
} }
}); });
...@@ -1561,7 +1567,6 @@ Licensed under the MIT license. ...@@ -1561,7 +1567,6 @@ Licensed under the MIT license.
setupTickGeneration(axis); setupTickGeneration(axis);
setTicks(axis); setTicks(axis);
snapRangeToTicks(axis, axis.ticks); snapRangeToTicks(axis, axis.ticks);
// find labelWidth/Height for axis
measureTickLabels(axis); measureTickLabels(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