Skip to content

60px default y-axis margin #1714

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

Closed
wants to merge 1 commit into from
Closed

Conversation

mbostock
Copy link
Member

Fixes #1451.

TODO: Investigate whether we can further increase the default margin to 80px in the case that an ordinal scale is used (in which case, the ticks tend to be longer) or a center labelAnchor is used (which is also the default for ordinal scales, and shares space with the tick labels). Both of these are tricky to do because the scale type is not known at the time the axis mark is constructed, and initializers are not allowed to affect position scales. We would need some sort of new hint or hook that would allow the axis mark to peek ahead at the scale type and adjust the default margin accordingly.

@mbostock mbostock requested a review from Fil June 22, 2023 17:51
@mbostock
Copy link
Member Author

I also don’t like that there’s too much left margin now in many of the examples. It would be nice to have a smarter heuristic. I don’t think it needs to be as precise as proper text metrics, but maybe something that can choose between a “small”, “medium”, and “large” default margin?

@Fil
Copy link
Contributor

Fil commented Jun 25, 2023

I want to explore an alternative where the axis mark would set the value of marginLeft (etc.) not to a number, but to a special value (Symbol["autoMargin"] or just a string, if we want to keep this usable from outside); the actual numeric value of that special autoMargin value would be computed in createDimensions—where the scales’ types and domains are already materialized. (#1722)

Fil added a commit that referenced this pull request Jun 25, 2023
alternative to #1714

closes #1451
@Fil Fil mentioned this pull request Jun 25, 2023
6 tasks
@mbostock
Copy link
Member Author

Maybe we could compute the labels for the y-axis, and use their length (simple text metrics) to estimate whether a small or large left/right margin is needed. And then we move on to do the same for the x-axis. This would also be useful to estimate a good default tickSpacing for the x-axis: if we have shorter or longer labels, we can adjust the default accordingly. The sparseCell test with ordinal axes is a good example of where we could use a small tickSpacing than the default (at least for x; the y default probably shouldn’t change).

@Fil Fil mentioned this pull request Aug 21, 2023
6 tasks
@mbostock
Copy link
Member Author

Closing in favor of #1722.

@mbostock mbostock closed this Sep 20, 2023
Fil added a commit that referenced this pull request Oct 12, 2023
alternative to #1714

closes #1451
Fil added a commit that referenced this pull request Jul 29, 2024
alternative to #1714

closes #1451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A larger default marginLeft for y axes
2 participants