Skip to content

Commit 74f594d

Browse files
committed
autorange call to account extra pad for inside tick labels
1 parent c262d4b commit 74f594d

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

src/plot_api/plot_api.js

+8
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ function plot(gd, data, layout, config) {
381381
// calculated. Would be much better to separate margin calculations from
382382
// component drawing - see https://github.com/plotly/plotly.js/issues/2704
383383
Plots.doAutoMargin,
384+
insideTickLabelsAutorange,
384385
Plots.previousPromises
385386
);
386387

@@ -395,6 +396,13 @@ function plot(gd, data, layout, config) {
395396
});
396397
}
397398

399+
function insideTickLabelsAutorange(gd) {
400+
var obj = gd._fullLayout._insideTickLabelsAutorange;
401+
if(!obj) return;
402+
gd._fullLayout._insideTickLabelsAutorangeDone = true;
403+
return relayout(gd, obj);
404+
}
405+
398406
function emitAfterPlot(gd) {
399407
var fullLayout = gd._fullLayout;
400408

src/plots/cartesian/axes.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -3147,11 +3147,19 @@ axes.drawLabels = function(gd, ax, opts) {
31473147
});
31483148
}
31493149

3150-
if(
3151-
(ax._anchorAxis || {}).autorange &&
3152-
(ax.ticklabelposition || '').indexOf('inside') !== -1
3153-
) {
3154-
seq.push(computeFinalTickLabelBoundingBoxes);
3150+
if(!gd._fullLayout._insideTickLabelsAutorangeDone) {
3151+
var anchorAxisAutorange = (ax._anchorAxis || {}).autorange;
3152+
if(
3153+
anchorAxisAutorange &&
3154+
(ax.ticklabelposition || '').indexOf('inside') !== -1
3155+
) {
3156+
if(!fullLayout._insideTickLabelsAutorange) {
3157+
fullLayout._insideTickLabelsAutorange = {};
3158+
}
3159+
fullLayout._insideTickLabelsAutorange[ax._anchorAxis._name + '.autorange'] = anchorAxisAutorange;
3160+
3161+
seq.push(computeFinalTickLabelBoundingBoxes);
3162+
}
31553163
}
31563164

31573165
var done = Lib.syncOrAsync(seq);
306 Bytes
Loading
148 Bytes
Loading

0 commit comments

Comments
 (0)