-
Notifications
You must be signed in to change notification settings - Fork 43
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
Axis labels overlap if size is chosen too small #87
Comments
#72 is somewhat related to this. |
@TheGreatRefrigerator Would you mind taking a look at this proof-of-concept branch? The PoC implements two different algorithms that are documented inline (look for Some questions that we'll need to address going forward:
|
@mrubli i've had a quick glance at the branch, but wasn't able to test it yet. I will be on vacation next week and will take a proper look at it afterwards. It seems to me, that both algorithms will be fine for "normal" use cases (if you don't use jquery to make it resizable by hand) Still i was thinking of a way that might improve the speed. e.g. assume a default lable width of 5 digits that are let's say 50 px each. if you have a width of 300 (for the graph part, not the whole plugin, need to account for that too) there will be "place" for 6 labels and the tick count can be set accordingly. Having such an approach it will be a "simple" calculation that might speed up the dynamic resizing by hand considerably.
definitely. It is prefered that the heightgraph can take care of this and you don't need to trial and error until you have the right tick combinations.
I was only testing with one single example when i introduced that change. I observed that i needed to raise the x and y ticks a lot to actually see an effect. The exponential setting was making sense for the setting of the example, but not in general i realized afterwards. The passing of the tick values should make sense in a way. |
I've solved it by using a solution from the original repository which derives the tick settings from height and width as well. |
Let me check it out. I had been thinking some more about this and was mostly worried about the case where users style the axis labels and end up using a larger font. I'm afraid that method might break down in that scenario. |
Ah i see, I still think it should be calculated by using the width and height instead of iterating over all labels. |
I am worried about both 😬 I just don't like the idea of hiding labels conditionally after generating them. But the problem currently is me using the whole width instead of the svg width 🤦 This could be passed as additional parameters to the heightgraph. How exactly are you styling the fonts currently? One additional thing reducing the overlap for the x would be #34 |
Can you check again with e36e130 |
I'm more worried about the performance than the complexity. After a bit of cleanup the complexity seems manageable. Let me do some measurements on the performance to get an idea how much time it takes for the iteration method.
There's something that feels unclean about it, I agree.
I understand the idea but the main problem with passing layout-related options is that you have to mix code with style. From the perspective of a library user that's not a very desirable approach.
I just put this in the CSS:
(In a real application I probably wouldn't use px as a unit, though.)
Actually, I like that one. It's a great way to save space and clean up the graph a bit, especially when you think about internationalization. In Chinese "20 km" would read "20公里" and having the unit after each label just looks a bit "overloaded". |
That fix definitely improve things. 👍
Perhaps we can leave it as is and see if people run into problems during practical use? I'll find out shortly when I get to the styling part of my own use of the library. Either way, I'll still clean up and benchmark my original proposal, just because I'm curious and because it's nice to archive things in a clean state in case you need it one day. 😄 |
I would leave it like this for now too, it should cover most cases :)
Yeah! It's always sad if you put some effort into doing something and it's not used. Best regards |
If the size of the height graph is too small the axis labels start to overlap:
With the merge of #84 (also see the discussion there) this has become more obvious and requires client-side minimum sizes (see #86 for an example of how this is done).
It would be desirable to have a more dynamic approach that automatically adjusts the number of axis ticks to avoid this problem.
I'm going to take a stab at this, I just wanted to create an issue first.
The text was updated successfully, but these errors were encountered: