From 53b3add094590ffc543b7f577522d0f4098c88ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 11 Oct 2019 16:54:36 -0400 Subject: [PATCH 1/2] 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 --- src/plots/cartesian/axes.js | 2 +- src/plots/plots.js | 2 +- test/jasmine/tests/axes_test.js | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 722e95e06a2..2f3c4c7f59c 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -1942,7 +1942,7 @@ axes.drawOne = function(gd, ax, opts) { ax.title.font.size; } - if(ax.mirror) { + if(ax.mirror && ax.anchor !== 'free') { mirrorPush = {x: 0, y: 0, r: 0, l: 0, t: 0, b: 0}; mirrorPush[sMirror] = ax.linewidth; diff --git a/src/plots/plots.js b/src/plots/plots.js index cb11473468b..a76591fb702 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -927,7 +927,7 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa // this loop can be costly, so only compute it when required if(ax._counterAxes.length && ( (ax.spikemode && ax.spikemode.indexOf('across') !== -1) || - (ax.automargin && ax.mirror) || + (ax.automargin && ax.mirror && ax.anchor !== 'free') || Registry.getComponentMethod('rangeslider', 'isVisible')(ax) )) { var min = 1; diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index d5539ab00fe..e51bd397ead 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -3468,6 +3468,33 @@ describe('Test axes', function() { .catch(failTest) .then(done); }); + + it('should handle cases with free+mirror axes', function(done) { + Plotly.plot(gd, [{ + y: [1, 2, 1] + }], { + xaxis: { + ticks: 'outside', + mirror: 'ticks', + anchor: 'free', + automargin: true + }, + yaxis: { + showline: true, + linewidth: 2, + mirror: 'all', + anchor: 'free', + automargin: true + } + }) + .then(function() { + // N.B. no '.automargin.mirror' + expect(Object.keys(gd._fullLayout._pushmargin)) + .toEqual(['x.automargin', 'y.automargin', 'base']); + }) + .catch(failTest) + .then(done); + }); }); describe('zeroline visibility logic', function() { From 70bfd5074516ae1279968e060a36d4c08b75d931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 11 Oct 2019 17:05:50 -0400 Subject: [PATCH 2/2] add one more flaky tag in transition_test.js --- test/jasmine/tests/transition_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/transition_test.js b/test/jasmine/tests/transition_test.js index 39660a076b8..0bbef67eb53 100644 --- a/test/jasmine/tests/transition_test.js +++ b/test/jasmine/tests/transition_test.js @@ -1189,7 +1189,7 @@ describe('Plotly.react transitions:', function() { .then(done); }); - it('should update ranges of date and category axes', function(done) { + it('@flaky should update ranges of date and category axes', function(done) { Plotly.plot(gd, [ {x: ['2018-01-01', '2019-01-01', '2020-01-01'], y: [1, 2, 3]}, {x: ['a', 'b', 'c'], y: [1, 2, 3], xaxis: 'x2', yaxis: 'y2'}