Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard against mirrored+automargin anchor:'free' axes #4273

Merged
merged 2 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/transition_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand Down