8000 Fix for #7416: Hidden ticklabels with ticklabelposition "inside" take up plot space by my-tien · Pull Request #7417 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fix for #7416: Hidden ticklabels with ticklabelposition "inside" take up plot space #7417

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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...
  • Loading branch information
my-tien committed May 20, 2025
commit 846c0ab5fd8c09b9eb21f149a240ab6e3ba49f95
34 changes: 28 additions & 6 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2946,20 +2946,42 @@ function calcLabelLevelBbox(ax, cls, mainLinePositionShift) {
bottom = -Infinity;
left = Infinity;
right = -Infinity;
var xAxis = ax._id.charAt(0) === 'x';
ax._selections[cls].each(function() {
var thisLabel = selectTickLabel(this);
var hidden = thisLabel.style('display') === 'none';
// Use parent node <g.(x|y)tick>, to make Drawing.bBox
// retrieve a bbox computed with transform info
//
// To improve perf, it would be nice to use `thisLabel.node()`
// (like in fixLabelOverlaps) instead and use Axes.getPxPosition
// together with the makeLabelFns outputs and `tickangle`
// to compute one bbox per (tick value x tick style)
if (hidden) {
// turn on label display temporarily to calculate its bbox
thisLabel.style('display', null);
}
var bb = Drawing.bBox(thisLabel.node().parentNode);
top = Math.min(top, bb.top);
bottom = Math.max(bottom, bb.bottom);
left = Math.min(left, bb.left);
right = Math.max(right, bb.right);
if (hidden) {
selectTickLabel(this).style('display', 'none');
}
var currentTop = bb.top;
var currentBottom = bb.bottom;
var currentLeft = bb.left;
var currentRight = bb.right;
if (hidden) {
if (xAxis) {
currentTop = top;
currentBottom = bottom;
} else {
currentLeft = left;
currentRight = right;
}
}
top = Math.min(top, currentTop);
bottom = Math.max(bottom, currentBottom);
left = Math.min(left, currentLeft);
right = Math.max(right, currentRight);
});
} else {
var dummyCalc = axes.makeLabelFns(ax, mainLinePositionShift);
Expand Down Expand Up @@ -3707,8 +3729,8 @@ axes.drawLabels = function(gd, ax, opts) {
var t = thisLabel.select('text');
if(adjust) {
if(hideOverflow) t.style('display', 'none'); // hidden
} else {
t.style('display', null); // visible
} else if(t.node().style.display !== 'none'){
t.style('display', null);

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