Skip to content

Commit 846c0ab

Browse files
committed
Try fixing failed baseline test container-colorbar-vertical-w-margin
- in calculatelabelLevelBbox bbox measurement for hidden labels was broken, because of display none - display 'none' led to repeated calls of adjustTicklabelOverflow that set display to null, then to none, then to null...
1 parent b546d61 commit 846c0ab

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/plots/cartesian/axes.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,20 +2946,42 @@ function calcLabelLevelBbox(ax, cls, mainLinePositionShift) {
29462946
bottom = -Infinity;
29472947
left = Infinity;
29482948
right = -Infinity;
2949+
var xAxis = ax._id.charAt(0) === 'x';
29492950
ax._selections[cls].each(function() {
29502951
var thisLabel = selectTickLabel(this);
2952+
var hidden = thisLabel.style('display') === 'none';
29512953
// Use parent node <g.(x|y)tick>, to make Drawing.bBox
29522954
// retrieve a bbox computed with transform info
29532955
//
29542956
// To improve perf, it would be nice to use `thisLabel.node()`
29552957
// (like in fixLabelOverlaps) instead and use Axes.getPxPosition
29562958
// together with the makeLabelFns outputs and `tickangle`
29572959
// to compute one bbox per (tick value x tick style)
2960+
if (hidden) {
2961+
// turn on label display temporarily to calculate its bbox
2962+
thisLabel.style('display', null);
2963+
}
29582964
var bb = Drawing.bBox(thisLabel.node().parentNode);
2959-
top = Math.min(top, bb.top);
2960-
bottom = Math.max(bottom, bb.bottom);
2961-
left = Math.min(left, bb.left);
2962-
right = Math.max(right, bb.right);
2965+
if (hidden) {
2966+
selectTickLabel(this).style('display', 'none');
2967+
}
2968+
var currentTop = bb.top;
2969+
var currentBottom = bb.bottom;
2970+
var currentLeft = bb.left;
2971+
var currentRight = bb.right;
2972+
if (hidden) {
2973+
if (xAxis) {
2974+
currentTop = top;
2975+
currentBottom = bottom;
2976+
} else {
2977+
currentLeft = left;
2978+
currentRight = right;
2979+
}
2980+
}
2981+
top = Math.min(top, currentTop);
2982+
bottom = Math.max(bottom, currentBottom);
2983+
left = Math.min(left, currentLeft);
2984+
right = Math.max(right, currentRight);
29632985
});
29642986
} else {
29652987
var dummyCalc = axes.makeLabelFns(ax, mainLinePositionShift);
@@ -3707,8 +3729,8 @@ axes.drawLabels = function(gd, ax, opts) {
37073729
var t = thisLabel.select('text');
37083730
if(adjust) {
37093731
if(hideOverflow) t.style('display', 'none'); // hidden
3710-
} else {
3711-
t.style('display', null); // visible
3732+
} else if(t.node().style.display !== 'none'){
3733+
t.style('display', null);
37123734

37133735
if(side === 'bottom' || side === 'right') {
37143736
visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left);

0 commit comments

Comments
 (0)