Skip to content

Commit cb2032a

Browse files
authored
Merge pull request #4273 from plotly/ax-automargin-mirror+free-check
Guard against mirrored+autorange anchor:'free' axes
2 parents 8230da5 + 70bfd50 commit cb2032a

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/plots/cartesian/axes.js

+1-1
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

+1-1
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

+27
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() {

test/jasmine/tests/transition_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ describe('Plotly.react transitions:', function() {
11891189
.then(done);
11901190
});
11911191

1192-
it('should update ranges of date and category axes', function(done) {
1192+
it('@flaky should update ranges of date and category axes', function(done) {
11931193
Plotly.plot(gd, [
11941194
{x: ['2018-01-01', '2019-01-01', '2020-01-01'], y: [1, 2, 3]},
11951195
{x: ['a', 'b', 'c'], y: [1, 2, 3], xaxis: 'x2', yaxis: 'y2'}

0 commit comments

Comments
 (0)