Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
archmoj merged 17 commits intoplotly:masterfrommy-tien:label-spacing
Jul 25, 2025

Conversation

@my-tien
Copy link
Contributor

@my-tienmy-tien commentedMay 6, 2025
edited
Loading

In this PR the text of hidden ticklabels is removed so that they don't take up space anymore.

Before the fix (in upper subplot an invisible label "100" takes up space):

image

After the fix (the vertical grid lines in the subplots are aligned with each other as expected):

image

Fixes issue:#7416

DisclaimerI am required to add that…

the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

Hidden ticklabels don't take up space anymore.
…ke up space.Also use floating point comparison in "Test axes minor ticks"
@gvwilsongvwilson added communitycommunity contribution P1needed for current cycle fixfixes something broken labelsMay 8, 2025
@alexcjohnson
Copy link
Collaborator

Nice find and diagnosis@my-tien! I wonder though if there's a better way to do this - specifically, adding this whole extra loop at the end, in addition to being unnecessary vs. just doing the desired thing from the start, I worry it will cause those labels to be missing later like if you drag the axis around, either during or after the drag.

Instead, I wonder if we can avoid this extra step by instead ofopacity: 0 | 1 usedisplay: none | block here:

thisText.style('opacity',1);// visible

and here:

if(hideOverflow)t.style('opacity',0);// hidden
}else{
t.style('opacity',1);// visible

Because unlikeopacity: 0,display: none causesgetBoundingClientRect to give zero size.

@my-tien
Copy link
ContributorAuthor

Hey Alex, thanks a lot for taking the time! 👍
You are absolutely right, in fact I tried to do this exact same change before, but did it incorrectly: I triedt.style('display', null), but of course it should bet.style('display', 'none'). Now I tried it correctly and it seems to work fine. I will push an update later today.

… mode to none.This is actually what we want: the label should not be visible and not take up space.
@my-tien
Copy link
ContributorAuthor

@alexcjohnson Pushed new implementation withdisplay: 'none' | null as is being done at several other locations in axes.js.

alexcjohnson reacted with hooray emoji

@alexcjohnson
Copy link
Collaborator

@my-tien this looks great. There are some more test failures inaxes_test.js, seehttps://app.circleci.com/pipelines/github/plotly/plotly.js/11937/workflows/35ad298f-0a05-44b8-95de-f8adbfef3f09/jobs/264167 - as mentioned@emilykl is working on the image test failures in#7418 but please make sure thatonly image tests are failing 😅

@my-tien
Copy link
ContributorAuthor

The failing tests were exactly those I adjusted so that they passed on my machine. I reverted the changes.

@alexcjohnson
Copy link
Collaborator

Excellent, looks great! This time the image tests actually ran, and for some reasoncontainer-colorbar-vertical-w-margin failed to render in both cases - can you try this mock on your branch and see if something really did break there? Once that passes we'll also need a baseline image for your new mock, but that's easiest to do off the artifacts in thetest-baselines job, once we get to that point.

- 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...
@my-tien
Copy link
ContributorAuthor

my-tien commentedMay 20, 2025
edited
Loading

So the issue is related to automargin logic: A bbox was calculated from thedisplay: 'none' label ifautomargin was set totrue . I also saw thatadjustTicklabelOverflow was called again and again, alternating the label display betweennull and'none'.
I now have new failing jasmine tests which I'll have to figure out.

Comments on my attempted fix welcomed as I'm not yet very clear about the required rendering and re-rendering steps.

@my-tien
Copy link
ContributorAuthor

Okay, I think I understand a little bit more what's going on. Next commit incoming soon... But this change will probably change a number of baseline images because hidden tick labels affected a couple of them.

@emilykl
Copy link
Contributor

emilykl commentedMay 21, 2025
edited
Loading

@my-tien Likewise please mergemainmaster into this branch to take advantage of the changes in#7418 . (I'm not sure you're actually hitting those issues in this branch, but just in case.)

my-tien reacted with heart emoji

…n labelsThis is a second attempt after846c0ab in which I tried to restore the previous behavior of calcLabelLevelBbox.I now think the hidden label should not contribute to the resulting bbox at all, because it's hidden.This will break baseline tests but should be the correct behavior.
@emilykl
Copy link
Contributor

emilykl commentedMay 22, 2025
edited
Loading

@alexcjohnson@my-tien One interesting case from the image diffs -- I don't think the rightward image iswrong, since it was kind of just a fortunate edge case that the gridlines were aligned before, but for a user who finds themself in this situation, is there an easy way in the figure definition to force the gridlines to be aligned?

mainmy-tien:label-spacing
ticklabelposition-bimage

@emilykl
Copy link
Contributor

@my-tien Thecontainer-colorbar image diffs still seem wrong to me (given the way the legend extends off the bottom of the chart) -- are you still working on theautomargin behavior?

Otherwise this is looking good to me.

@my-tien
Copy link
ContributorAuthor

my-tien commentedMay 23, 2025
edited
Loading

Hi Emily,
thanks for looking at this!

@my-tien Thecontainer-colorbar image diffs still seem wrong to me (given the way the legend extends off the bottom of the chart) -- are you still working on theautomargin behavior?

Otherwise this is looking good to me.

I'm not 100% sure what legend you mean, do you mean the yellow box around the colorbar?
(previous)
image
(new)
image

The colorbar container and the x-axis ticks are now cut-off because the hidden -0.5 label on the y-axis doesn't take up space anymore and therefore doesn't push down the margins, i.e. same behavior as whenyaxis.automargin is set to false. (I also think it is correct, that -0.5 is hidden, because the defaultticklabeloverflow behavior for this axis ishide past (graph)div).
If I now setlayout.title.automargin: false as well, the chart is exactly 300 px high as specified in the layout height.

Compare to the current behavior when automargin is completely turned off, the colorbar container is also cut-off. So if this is a bug, I think it happens somewhere else:
image
codepen

@alexcjohnson
Copy link
Collaborator

One interesting case from the image diffs -- I don't think the rightward image is wrong, since it was kind of just a fortunate edge case that the gridlines were aligned before, but for a user who finds themself in this situation, is there an easy way in the figure definition to force the gridlines to be aligned?

The main situation you'd want these aligned is when they're either literally the same x axis or the two x axes are matched. Hopefully that's handled correctly already? Absent that I'd say the behavior here is correct.

Thecontainer-colorbar image diffs still seem wrong to me (given the way the legend extends off the bottom of the chart)

Hmph there are a bunch of issues here I'm not sure we ever really considered re: automargin, and I think@my-tien is right that this is not a problem with this PR but with colorbars. This colorbar has default position (y=0.5) and size (len=1), which means it extends beyond the plot area only due to however we decide to treat its border: does the border fitinside its specified space, in which case the thicker you make the border the more it needs to squeeze its content, or does the border gooutside the specified space, in which case it should impact margins. Or is the midline of the border on the specified box, in which case it's a bit of each? I don't know the right answer here but this shouldn't block this PR, we should make a new issue and consider how we can best align the behavior with other components (legends, text annotations, axis lines).

There are also the tick marks, which are apparently not hidden on the x axis but don't trigger automargin even though arguably they should. That's another issue independent of this PR, though I'd call that relatively low-priority: how often do real plots have tick marks with no labels at all?

my-tien reacted with thumbs up emoji

@my-tien
Copy link
ContributorAuthor

Just to make sure: from my side no additional changes are required since the existing problems weren't caused by this PR, right?

@emilykl
Copy link
Contributor

Just to make sure: from my side no additional changes are required since the existing problems weren't caused by this PR, right?

@my-tien I believe that's correct, I don't think the Jasmine test failures are related.

Could you download the changed baseline images from the "Artifacts" tab of thetest-baselines CircleCI job, and commit them to this PR? You may need to push a dummy commit first to trigger the pipeline again, I wasn't able to re-run it manually.

@emilykl
Copy link
Contributor

Could you also mergemaster into this branch again? When you do so, that should trigger the pipeline.

my-tien reacted with thumbs up emoji

@my-tien
Copy link
ContributorAuthor

Merged and updated baseline images

@my-tien
Copy link
ContributorAuthor

Hi@emilykl, is there any chance for this PR to make it into the next release?

@emilykl
Copy link
Contributor

@my-tien Yes I hope we can get this into the next release. I need to figure out why the test pipelines are failing which I hope to do today (no action required on your part). Thank you for your patience.

@archmoj
Copy link
Contributor

@my-tien Could you please merge master into this branch?
Thank you.

my-tien reacted with thumbs up emoji

@emilykl
Copy link
Contributor

@my-tien, could you please cherry-pick commitdfcdfdf onto this branch?

my-tien and archmoj reacted with thumbs up emoji

Copy link
Contributor

@archmojarchmoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

💃

@archmojarchmoj merged commit7d40224 intoplotly:masterJul 25, 2025
5 checks passed
@my-tien
Copy link
ContributorAuthor

my-tien commentedJul 28, 2025
edited
Loading

Thanks@emilykl and@archmoj and@alexcjohnson! <3

archmoj reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alexcjohnsonalexcjohnsonalexcjohnson left review comments

@emilyklemilyklemilykl left review comments

+1 more reviewer

@archmojarchmojarchmoj approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@alexcjohnsonalexcjohnson

Labels

communitycommunity contributionfixfixes something brokenP1needed for current cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@my-tien@alexcjohnson@emilykl@archmoj@gvwilson

[8]ページ先頭

©2009-2025 Movatter.jp