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

feature request: margins automatically adjust to tick values #140

Closed
knackjax opened this issue Jan 31, 2018 · 6 comments
Closed

feature request: margins automatically adjust to tick values #140

knackjax opened this issue Jan 31, 2018 · 6 comments

Comments

@knackjax
Copy link
Contributor

I have tick values which I do not know the max text size. Long tick values strings cut off if the margin is too small as shown in https://www.webpackbin.com/bins/-KylBOM-OLUpXZ8zOhY-.

It would be nice if we could have it automatically adjust margins so we don't have to eyeball.

@knackjax
Copy link
Contributor Author

knackjax commented Feb 2, 2018

closing ticket since this is pretty specific. I used a third party library to precompute svg width to resize margins called 'svg-text-size' and no longer need this implemented

@knackjax knackjax closed this as completed Feb 2, 2018
@cfinnegan
Copy link

Can this be reopened? I think allowing margins to be responsive to the width of the legend is not niche and very useful.

@anthonyp-usafacts
Copy link

Bump!

@mmirus
Copy link

mmirus commented Apr 27, 2023

Yes, this would be very useful!

@plouc
Copy link
Owner

plouc commented Apr 27, 2023

While this might be feasible, I'm not planning to implement this, this would be extremely complex to implement with the current approach as axes are typically computed once we already have scales, which depends on those margins.

Also I'm not sure it's ideal to have the size of a chart vary depending on the length of its ticks labels, although I can understand that it could be practical in certain situations.

Implementing such feature would certainly lead to other problems, like what happens if the labels take all the space and the chart is not visible anymore? We would probably need to introduce new constraints.

So IMO the complexity this could introduce, and the potential issues it could lead to, outweigh the benefits.

This can maybe be implemented naively in user land by computing the maximum length of the labels and define some kind of fixed width per character, and define margins according to this, but this wouldn't be a robust solution, a proper solution would need to consider the actual computed size of the labels (for both SVG and canvas based implementations).

@mmirus
Copy link

mmirus commented Apr 28, 2023

Understood. Thanks for the detailed response!

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

No branches or pull requests

5 participants