Skip to content

Commit 6a052c4

Browse files
committed
hide ticks overlapping inside tick labels on all overlaying axes
1 parent 296dbfb commit 6a052c4

File tree

1 file changed

+51
-36
lines changed

1 file changed

+51
-36
lines changed

src/plots/cartesian/axes.js

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,48 +3124,63 @@ axes.drawLabels = function(gd, ax, opts) {
31243124
} // TODO: hide mathjax?
31253125
});
31263126

3127-
if(ax._anchorAxis) {
3128-
ax._anchorAxis._visibleLabelMin = visibleLabelMin;
3129-
ax._anchorAxis._visibleLabelMax = visibleLabelMax;
3127+
for(var subplot in fullLayout._plots) {
3128+
var plotinfo = fullLayout._plots[subplot];
3129+
if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue;
3130+
var anchorAx = isX ? plotinfo.yaxis : plotinfo.xaxis;
3131+
if(anchorAx) {
3132+
anchorAx['_visibleLabelMin_' + ax._id] = visibleLabelMin;
3133+
anchorAx['_visibleLabelMax_' + ax._id] = visibleLabelMax;
3134+
}
31303135
}
31313136
};
31323137

31333138
ax._hideCounterAxisInsideTickLabels = function(partialOpts) {
3134-
if(insideTicklabelposition(ax._anchorAxis || {})) {
3135-
(partialOpts || [
3136-
ZERO_PATH,
3137-
GRID_PATH,
3138-
TICK_PATH,
3139-
TICK_TEXT
3140-
]).forEach(function(e) {
3141-
var isPeriodLabel =
3142-
e.K === 'tick' &&
3143-
e.L === 'text' &&
3144-
ax.ticklabelmode === 'period';
3145-
3146-
var sel;
3147-
if(e.K === ZERO_PATH.K) sel = opts.plotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl');
3148-
else if(e.K === GRID_PATH.K) sel = opts.plotinfo.gridlayer.selectAll('.' + ax._id);
3149-
else sel = opts.plotinfo[ax._id.charAt(0) + 'axislayer'];
3150-
3151-
sel.each(function() {
3152-
var w = d3.select(this);
3153-
if(e.L) w = w.selectAll(e.L);
3154-
3155-
w.each(function(d) {
3156-
var q = ax.l2p(
3157-
isPeriodLabel ? getPosX(d) : d.x
3158-
) + ax._offset;
3159-
3160-
var t = d3.select(this);
3161-
if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) {
3162-
t.style('display', 'none'); // hidden
3163-
} else if(e.K === 'tick') {
3164-
t.style('display', null); // visible
3165-
}
3139+
var isX = ax._id.charAt(0) === 'x';
3140+
for(var subplot in fullLayout._plots) {
3141+
var plotinfo = fullLayout._plots[subplot];
3142+
if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue;
3143+
var anchorAx = isX ? plotinfo.yaxis : plotinfo.xaxis;
3144+
3145+
if(anchorAx && insideTicklabelposition(anchorAx)) {
3146+
(partialOpts || [
3147+
ZERO_PATH,
3148+
GRID_PATH,
3149+
TICK_PATH,
3150+
TICK_TEXT
3151+
]).forEach(function(e) {
3152+
var isPeriodLabel =
3153+
e.K === 'tick' &&
3154+
e.L === 'text' &&
3155+
ax.ticklabelmode === 'period';
3156+
3157+
var sel;
3158+
if(e.K === ZERO_PATH.K) sel = opts.plotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl');
3159+
else if(e.K === GRID_PATH.K) sel = opts.plotinfo.gridlayer.selectAll('.' + ax._id);
3160+
else sel = opts.plotinfo[ax._id.charAt(0) + 'axislayer'];
3161+
3162+
sel.each(function() {
3163+
var w = d3.select(this);
3164+
if(e.L) w = w.selectAll(e.L);
3165+
3166+
w.each(function(d) {
3167+
var q = ax.l2p(
3168+
isPeriodLabel ? getPosX(d) : d.x
3169+
) + ax._offset;
3170+
3171+
var t = d3.select(this);
3172+
if(
3173+
q < ax['_visibleLabelMax_' + anchorAx._id] &&
3174+
q > ax['_visibleLabelMin_' + anchorAx._id]
3175+
) {
3176+
t.style('display', 'none'); // hidden
3177+
} else if(e.K === 'tick') {
3178+
t.style('display', null); // visible
3179+
}
3180+
});
31663181
});
31673182
});
3168-
});
3183+
}
31693184
}
31703185
};
31713186

0 commit comments

Comments
 (0)