Skip to content

Commit

Permalink
Merge pull request #1981 from plotly/axis-visible-clear-title
Browse files Browse the repository at this point in the history
Clear axis title on full axis redraw
  • Loading branch information
etpinard committed Sep 5, 2017
2 parents fc5a73a + db07f46 commit b1368f6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,8 @@ axes.doTicks = function(gd, axid, skipTitle) {
.selectAll('path').remove();
plotinfo.zerolinelayer
.selectAll('path').remove();
fullLayout._infolayer.select('.g-' + xa._id + 'title').remove();
fullLayout._infolayer.select('.g-' + ya._id + 'title').remove();
});
}

Expand Down
42 changes: 42 additions & 0 deletions test/jasmine/tests/cartesian_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,46 @@ describe('subplot creation / deletion:', function() {
.catch(failTest)
.then(done);
});

it('clear axis ticks, labels and title when relayout an axis to `*visible:false*', function(done) {
function _assert(xaxis, yaxis) {
var g = d3.select('.subplot.xy');
var info = d3.select('.infolayer');

expect(g.selectAll('.xtick').size()).toBe(xaxis[0], 'x tick cnt');
expect(g.selectAll('.gridlayer > .xgrid').size()).toBe(xaxis[1], 'x gridline cnt');
expect(info.selectAll('.g-xtitle').size()).toBe(xaxis[2], 'x title cnt');

expect(g.selectAll('.ytick').size()).toBe(yaxis[0], 'y tick cnt');
expect(g.selectAll('.gridlayer > .ygrid').size()).toBe(yaxis[1], 'y gridline cnt');
expect(info.selectAll('.g-ytitle').size()).toBe(yaxis[2], 'y title cnt');
}

Plotly.plot(gd, [{
y: [1, 2, 1]
}], {
xaxis: {title: 'X'},
yaxis: {title: 'Y'}
})
.then(function() {
_assert([5, 4, 1], [6, 6, 1]);
return Plotly.relayout(gd, 'xaxis.visible', false);
})
.then(function() {
_assert([0, 0, 0], [6, 6, 1]);
return Plotly.relayout(gd, 'yaxis.visible', false);
})
.then(function() {
_assert([0, 0, 0], [0, 0, 0]);
return Plotly.relayout(gd, {
'xaxis.visible': true,
'yaxis.visible': true
});
})
.then(function() {
_assert([5, 4, 1], [6, 6, 1]);
})
.catch(failTest)
.then(done);
});
});

0 comments on commit b1368f6

Please sign in to comment.