Refactoring code. Change Y-Zero to Y-Level.

This commit is contained in:
ilgizar
2018-02-20 16:58:49 +05:00
parent 57013d2228
commit 7eeb68b590
4 changed files with 117 additions and 78 deletions

View File

@ -1622,14 +1622,24 @@ Licensed under the MIT license.
return axis.show || axis.reserveSpace;
});
$.each(allocatedAxes, function (_, axis) {
// make the ticks
setupTickGeneration(axis);
setTicks(axis);
snapRangeToTicks(axis, axis.ticks);
// find labelWidth/Height for axis
measureTickLabels(axis);
});
var snaped = false;
for (var i = 0; i < 2; i++) {
$.each(allocatedAxes, function (_, axis) {
// make the ticks
setupTickGeneration(axis);
setTicks(axis);
snaped = snapRangeToTicks(axis, axis.ticks) || snaped;
// find labelWidth/Height for axis
measureTickLabels(axis);
});
if (snaped) {
executeHooks(hooks.processRange, []);
snaped = false;
} else {
break;
}
}
// with all dimensions calculated, we can compute the
// axis bounding boxes, start from the outside
@ -1646,6 +1656,7 @@ Licensed under the MIT license.
});
}
plotWidth = surface.width - plotOffset.left - plotOffset.right;
plotHeight = surface.height - plotOffset.bottom - plotOffset.top;
@ -1879,13 +1890,19 @@ Licensed under the MIT license.
}
function snapRangeToTicks(axis, ticks) {
var changed = false;
if (axis.options.autoscaleMargin && ticks.length > 0) {
// snap to ticks
if (axis.options.min == null)
if (axis.options.min == null) {
axis.min = Math.min(axis.min, ticks[0].v);
if (axis.options.max == null && ticks.length > 1)
changed = true;
}
if (axis.options.max == null && ticks.length > 1) {
axis.max = Math.max(axis.max, ticks[ticks.length - 1].v);
changed = true;
}
}
return changed;
}
function draw() {