Skip to content

Commit 53b3add

Browse files
committed
guard against mirroed+autorange anchor:'free' axes
- anchor:'free' axes don't draw mirror ticks, so they never need to contribute to the automargin push
1 parent 25fe1c9 commit 53b3add

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/plots/cartesian/axes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ axes.drawOne = function(gd, ax, opts) {
19421942
ax.title.font.size;
19431943
}
19441944

1945-
if(ax.mirror) {
1945+
if(ax.mirror && ax.anchor !== 'free') {
19461946
mirrorPush = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0};
19471947

19481948
mirrorPush[sMirror] = ax.linewidth;

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa
927927
// this loop can be costly, so only compute it when required
928928
if(ax._counterAxes.length && (
929929
(ax.spikemode && ax.spikemode.indexOf('across') !== -1) ||
930-
(ax.automargin && ax.mirror) ||
930+
(ax.automargin && ax.mirror && ax.anchor !== 'free') ||
931931
Registry.getComponentMethod('rangeslider', 'isVisible')(ax)
932932
)) {
933933
var min = 1;

test/jasmine/tests/axes_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,6 +3468,33 @@ describe('Test axes', function() {
34683468
.catch(failTest)
34693469
.then(done);
34703470
});
3471+
3472+
it('should handle cases with free+mirror axes', function(done) {
3473+
Plotly.plot(gd, [{
3474+
y: [1, 2, 1]
3475+
}], {
3476+
xaxis: {
3477+
ticks: 'outside',
3478+
mirror: 'ticks',
3479+
anchor: 'free',
3480+
automargin: true
3481+
},
3482+
yaxis: {
3483+
showline: true,
3484+
linewidth: 2,
3485+
mirror: 'all',
3486+
anchor: 'free',
3487+
automargin: true
3488+
}
3489+
})
3490+
.then(function() {
3491+
// N.B. no '.automargin.mirror'
3492+
expect(Object.keys(gd._fullLayout._pushmargin))
3493+
.toEqual(['x.automargin', 'y.automargin', 'base']);
3494+
})
3495+
.catch(failTest)
3496+
.then(done);
3497+
});
34713498
});
34723499

34733500
describe('zeroline visibility logic', function() {

0 commit comments

Comments
 (0)