Skip to content
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

clipped axis labels #5404

Closed
nicolaskruchten opened this issue Jan 14, 2021 · 25 comments
Closed

clipped axis labels #5404

nicolaskruchten opened this issue Jan 14, 2021 · 25 comments
Labels
bug something broken feature something new

Comments

@nicolaskruchten
Copy link
Contributor

In this pen: https://codepen.io/nicolaskruchten/pen/BaLGYeW?editors=0010 the right-most xaxis ticklabel should not be rendered if it's being clipped like this. Note: ticklabelmode is being set to period in the layout.template and the clipped label has no data associated with it.

@archmoj
Copy link
Contributor

archmoj commented Mar 10, 2021

It does not appear to be a period ticklabelmode bug.
Looking at the red plot https://rreusser.github.io/plotly-mock-viewer/#date_axes this seems to be the expected behaviour for date axes mock unless we say we should have dropped axis labels that may go outside due to the zero or little specified margin?

@nicolaskruchten
Copy link
Contributor Author

I'm not sure I understand what you're seeing in that mock... nothing is clipped for me there

@nicolaskruchten
Copy link
Contributor Author

In the mock, I can pan the X axis and never get a clipped ticklabel, but in my codepen, panning the X axis always results in clipping, on both sides actually, not just the side with the inside ticklabel on the Y axis

@archmoj
Copy link
Contributor

archmoj commented Mar 10, 2021

Here is a codepen.

@nicolaskruchten
Copy link
Contributor Author

OK, with this pen I can see some clipping, yes. Oh I see, in the pen I posted above it's not the edge of the plotting area that's clipping, it's the edge of the figure altogether, because the margins are so small.

@nicolaskruchten
Copy link
Contributor Author

What kind of heuristic could we build that would avoid rendering this label? In this case there is no data in 2007, so there's not really much sense in rendering this label. Resolving #5502 wouldn't get rid of this, because the 2007 gridline doesn't intersect the Y ticklabels.

Maybe we need to just not render ticklabels if they'll be clipped by the margin. @alexcjohnson thoughts?

@nicolaskruchten
Copy link
Contributor Author

Maybe we need to just not render ticklabels if they'll be clipped by the margin

This is basically the requirement, yes.

@archmoj
Copy link
Contributor

archmoj commented Mar 11, 2021

The it should be labeled as a feature, right?

@nicolaskruchten
Copy link
Contributor Author

I still consider the current behaviour a bug: it's ugly and should not be the default.

@alexcjohnson
Copy link
Collaborator

Related: #3292 (nudge the first and last tick labels inward to fit within the axis span - though in this case removing these labels is better)

I'm a little worried about a blanket "remove tick labels that get clipped by the graph div boundaries" - that might catch too many things, like long category labels with automargin disabled. We would only remove those that get clipped in the axis direction, so for an x axis category labels going off the bottom would remain visible, just those that go off the right (or left) edge, most likely when the tickangle chooses 30º.

What about a new attribute axis.ticklabeloverflow with values 'allow' (default on category axes), 'remove' (default on all other axes), and perhaps eventually something like 'push' to support #3292. Though there's still a question of whether overflow refers to the subplot area or the graph div - with a single subplot and no margins the two are the same. By default I think we should only remove those that overflow the div, but there are cases like closely-spaced facets where labels can overlap each other and it may be nice to avoid this.

So perhaps an enum with five values: allow (default for category), 'remove past div' (default for others), 'remove past domain', and someday 'push to div' and 'push to domain'. Something like that would solve this particular issue as a bug, while still allowing flexibility for the user to choose other behaviors and for us to add new behaviors later.

@nicolaskruchten
Copy link
Contributor Author

That sounds great to me as a way forward, thanks for synthesizing :)

@archmoj archmoj added the feature something new label Mar 25, 2021
@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

I think instead of passing the div we should consider passing the range.
If one sets the left and right margins in the above graph we shouldn't render the label even if it maybe fit inside the div.
margin_r_20

@nicolaskruchten
Copy link
Contributor Author

I think Alex's framework above leaves room for that i.e. with 'remove past domain' but I don't think we want to implement that right now and we can't use it as the new default because that's too big a change. We should implement remove past div now though and make it the new default for v2.

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

OK.
On another note, while #3292 is all about range not domain the options could be
allow, remove past div, remove past domain, remove past range, push to div, push to domain, push to range. Right?

@nicolaskruchten
Copy link
Contributor Author

Per conversation just now, I think we agree that this is "domain" and "div" and not "range".

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

It looks we should not coerce ticklabeloverflow for inside tick labels. Correct?

@nicolaskruchten
Copy link
Contributor Author

Hehe, yes :)

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

Perhaps it would be cleaner if we default it to remove past domain for inside tick labels, considering the push and allow option can be useful in some scenarios.

@nicolaskruchten
Copy link
Contributor Author

Let's leave that out for now... this is for cases where the inside label is so long that it spans the whole subplot? Seems unlikely to happen very often

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

Let's leave that out for now... this is for cases where the inside label is so long that it spans the whole subplot? Seems unlikely to happen very often

Not only that; but also it would make our supplyDefaults logic and writing the logic for tick label adjustment function simpler.

@nicolaskruchten
Copy link
Contributor Author

I thought we agreed earlier that we wouldn't have anything related to range?

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

I thought we agreed earlier that we wouldn't have anything related to range?

Positive.That the domain 😀

@nicolaskruchten
Copy link
Contributor Author

Ok but for now let's just implement "remove past div" not anything domain related.

@archmoj
Copy link
Contributor

archmoj commented Apr 7, 2021

Ok but for now let's just implement "remove past div" not anything domain related.

We already did implement 'remove past domain' functionality for inside tick labels and I am going to reuse that function for div.

@nicolaskruchten
Copy link
Contributor Author

Can I see a demo of this remove past domain in action for inside tick labels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken feature something new
Projects
None yet
Development

No branches or pull requests

3 participants