Skip to content

Commit

Permalink
autorange call to account extra pad for inside tick labels
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Nov 18, 2020
1 parent c262d4b commit 74f594d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ function plot(gd, data, layout, config) {
// calculated. Would be much better to separate margin calculations from
// component drawing - see https://github.com/plotly/plotly.js/issues/2704
Plots.doAutoMargin,
insideTickLabelsAutorange,
Plots.previousPromises
);

Expand All @@ -395,6 +396,13 @@ function plot(gd, data, layout, config) {
});
}

function insideTickLabelsAutorange(gd) {
var obj = gd._fullLayout._insideTickLabelsAutorange;
if(!obj) return;
gd._fullLayout._insideTickLabelsAutorangeDone = true;
return relayout(gd, obj);
}

function emitAfterPlot(gd) {
var fullLayout = gd._fullLayout;

Expand Down
18 changes: 13 additions & 5 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3147,11 +3147,19 @@ axes.drawLabels = function(gd, ax, opts) {
});
}

if(
(ax._anchorAxis || {}).autorange &&
(ax.ticklabelposition || '').indexOf('inside') !== -1
) {
seq.push(computeFinalTickLabelBoundingBoxes);
if(!gd._fullLayout._insideTickLabelsAutorangeDone) {
var anchorAxisAutorange = (ax._anchorAxis || {}).autorange;
if(
anchorAxisAutorange &&
(ax.ticklabelposition || '').indexOf('inside') !== -1
) {
if(!fullLayout._insideTickLabelsAutorange) {
fullLayout._insideTickLabelsAutorange = {};
}
fullLayout._insideTickLabelsAutorange[ax._anchorAxis._name + '.autorange'] = anchorAxisAutorange;

seq.push(computeFinalTickLabelBoundingBoxes);
}
}

var done = Lib.syncOrAsync(seq);
Expand Down
Binary file modified test/image/baselines/ticklabelposition-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/ticklabelposition-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 74f594d

Please sign in to comment.