Skip to content

Commit c45ae12

Browse files
committed
simplify autorange for inside ticklabels
1 parent 9291457 commit c45ae12

11 files changed

+2
-41
lines changed

src/plots/cartesian/autorange.js

+2-41
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,10 @@ function makePadFn(fullLayout, ax, max) {
223223
if(axReverse) max = !max;
224224
}
225225

226-
var A = 0;
227-
var B = 0;
226+
var zero = 0;
228227
if(!isLinked(fullLayout, ax._id)) {
229-
A = padInsideLabelsOnAnchorAxis(ax, max);
230-
B = padInsideLabelsOnThisAxis(ax, max);
228+
zero = padInsideLabelsOnAnchorAxis(ax, max);
231229
}
232-
233-
var zero = Math.max(A, B);
234230
extrappad = Math.max(zero, extrappad);
235231

236232
// domain-constrained axes: base extrappad on the unconstrained
@@ -248,41 +244,6 @@ function makePadFn(fullLayout, ax, max) {
248244

249245
var TEXTPAD = 3;
250246

251-
function padInsideLabelsOnThisAxis(ax, max) {
252-
var ticklabelposition = ax.ticklabelposition || '';
253-
var has = function(str) {
254-
return ticklabelposition.indexOf(str) !== -1;
255-
};
256-
257-
if(!has('inside')) return 0;
258-
var isTop = has('top');
259-
var isLeft = has('left');
260-
var isRight = has('right');
261-
var isBottom = has('bottom');
262-
var isAligned = isBottom || isLeft || isTop || isRight;
263-
264-
if(
265-
(max && (isLeft || isBottom)) ||
266-
(!max && (isRight || isTop))
267-
) {
268-
return 0;
269-
}
270-
271-
// increase padding to make more room for inside tick labels of the axis
272-
var fontSize = ax.tickfont ? ax.tickfont.size : 12;
273-
var isX = ax._id.charAt(0) === 'x';
274-
var pad = (isX ? 1.2 : 0.6) * fontSize;
275-
276-
if(isAligned) {
277-
pad *= 2;
278-
pad += (ax.tickwidth || 0) / 2;
279-
}
280-
281-
pad += TEXTPAD;
282-
283-
return pad;
284-
}
285-
286247
function padInsideLabelsOnAnchorAxis(ax, max) {
287248
var pad = 0;
288249
var anchorAxis = ax._anchorAxis || {};
-1.12 KB
Loading
-3.18 KB
Loading
-1.2 KB
Loading
1.96 KB
Loading
15 Bytes
Loading
1.3 KB
Loading
1.78 KB
Loading
2.79 KB
Loading
-10.4 KB
Loading
1.52 KB
Loading

0 commit comments

Comments
 (0)