Skip to content

Commit e157374

Browse files
committed
Instead of removing text of hidden ticklabels, just set their display mode to none.
This is actually what we want: the label should not be visible and not take up space.
1 parent a287e90 commit e157374

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/plots/cartesian/axes.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,7 +3648,7 @@ axes.drawLabels = function(gd, ax, opts) {
36483648
'text-anchor': anchor
36493649
});
36503650

3651-
thisText.style('opacity', 1); // visible
3651+
thisText.style('display', null); // visible
36523652

36533653
if(ax._adjustTickLabelsOverflow) {
36543654
ax._adjustTickLabelsOverflow();
@@ -3706,9 +3706,9 @@ axes.drawLabels = function(gd, ax, opts) {
37063706

37073707
var t = thisLabel.select('text');
37083708
if(adjust) {
3709-
if(hideOverflow) t.style('opacity', 0); // hidden
3709+
if(hideOverflow) t.style('display', 'none'); // hidden
37103710
} else {
3711-
t.style('opacity', 1); // visible
3711+
t.style('display', null); // visible
37123712

37133713
if(side === 'bottom' || side === 'right') {
37143714
visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left);
@@ -3783,7 +3783,7 @@ axes.drawLabels = function(gd, ax, opts) {
37833783
q > ax['_visibleLabelMin_' + anchorAx._id]
37843784
) {
37853785
t.style('display', 'none'); // hidden
3786-
} else if(e.K === 'tick' && !idx) {
3786+
} else if(e.K === 'tick' && !idx && t.style('display') != 'none') {
37873787
t.style('display', null); // visible
37883788
}
37893789
});
@@ -3807,6 +3807,7 @@ axes.drawLabels = function(gd, ax, opts) {
38073807
var autoangle = null;
38083808

38093809
function fixLabelOverlaps() {
3810+
console.log("fix label overlaps!");
38103811
positionLabels(tickLabels, tickAngle);
38113812

38123813
// check for auto-angling if x labels overlap
@@ -3915,24 +3916,11 @@ axes.drawLabels = function(gd, ax, opts) {
39153916
}
39163917
}
39173918

3918-
function removeHiddenLabels() {
3919-
// Remove all hidden labels to prevent them from affecting the layout.
3920-
tickLabels.each(function(d) {
3921-
var thisLabel = d3.select(this);
3922-
var textNode = thisLabel.select('text').node();
3923-
var opacity = window.getComputedStyle(textNode).opacity;
3924-
if (opacity == '0') {
3925-
thisLabel.select('text').text('');
3926-
d3.select(textNode).text('');
3927-
}
3928-
});
3929-
}
3930-
39313919
if(ax._selections) {
39323920
ax._selections[cls] = tickLabels;
39333921
}
39343922

3935-
var seq = [allLabelsReady, removeHiddenLabels];
3923+
var seq = [allLabelsReady];
39363924

39373925
// N.B. during auto-margin redraws, if the axis fixed its label overlaps
39383926
// by rotating 90 degrees, do not attempt to re-fix its label overlaps

0 commit comments

Comments
 (0)