-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Top margin incorrect #12206
Comments
Thanks for reporting the issue @drmrbrewer In this particular design, you can set Internal note: Lines 6651 to 6671 in e62d541
In short: http://jsfiddle.net/BlackLabel/0ou3rfa4/ - both (top/bottom) spacings are set to zero, yet only bottom labels are close enough to the border. |
Thanks, @pawelfus. Is the I also find that there is still too much blank space for my use case. Take the following example, with title added: https://jsfiddle.net/5tb1xmvk/1/ Because I am trying to use every last bit of space, I have even reduced the https://jsfiddle.net/5tb1xmvk/ Is the extra blank space in the first example (even with |
It's a direct fix @drmrbrewer - instead of reserving space for labels automatically, you control it. Note that labels nicely fit in the space created by tickmarks. You can reduce extra space above by setting Extra space, in your demos with titles, is caused by |
@pawelfus aaah, I see. Yes, makes sense! Thanks.
ah yes, thanks... I really hated the negative margin kludge so I'm glad it's not necessary!
but in my case I still need to reduce https://jsfiddle.net/p8z2476t/ But this is really just particular to my use case where I'm trying to maximise actual chart size as far as possible. |
Ah, in that case, yes, |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! |
@pawelfus this issue was closed automatically but I don't see it as being completely resolved. I've been using the suggested solution, which has been working fine in general. Basically the solution was to set But now I'm in a situation where I want to make the format for the top axis labels customisable, so that I can no longer be sure how much space I need to reserve. Therefore, using the ticks to reserve space no longer works, but I also can't get the right amount of space to be reserved for the labels... or at least I can't adjust the y position of the labels without messing everything up. Example: https://jsfiddle.net/y2pj7gmb/ (press Run multiple times to show the effect of different label height) I have deliberately reduced |
Hey @drmrbrewer You can test this branch: Your demo without workarounds (negative |
Thanks, @pawelfus. The demo seems to suffer from a similar problem to my original post, in that it seems to be impossible to adjust the I'm trying to reduce the gap shown here: So I try to add a small positive https://jsfiddle.net/btx5qhwj/ I'm used to being able to adjust the |
Right, back to square one... I think I got it: https://jsfiddle.net/BlackLabel/o5wcehyv/1/ |
@pawelfus this is looking good 👍 |
@pawelfus there still seem to be some quirks. You say that "Now But now I'm now also looking at the behaviour of the labels on the bottom xAxis. Check the following example, which uses the same label setup for top and bottom: https://jsfiddle.net/bqcj163u/ Hit 'Run' several times... this now changes the vs: This (i.e. whether vs: The following is an example with fixed label format, and changing just https://jsfiddle.net/fm6zpcgL/ Sorry if this seems like pedantic pixel-peeping but in my use-case the positioning needs to be very precise (and predictable) because space is very limited and the chart features and axis labels etc are packed in as compactly as possible :-) |
@pawelfus any further thoughts on this? |
Hi @drmrbrewer My apologies for not replying sooner. I will try a different approach next week. It's a quite tricky case, because I don't want to cause any regressions (current PR has plenty of them..) |
Hi @pawelfus... no problem, and I completely understand that it is tricky for you, potentially with lots of unintended consequences for any change you might make. As I mentioned, adjusting the |
Hi @drmrbrewer
Fixed, my changes don't affect the bottom xAxis anymore
I can't change it. After digging further, I consider this is a bug with Current solution: https://jsfiddle.net/BlackLabel/h6twmcr1/11/ |
@pawelfus the y positioning of the bottom axis label is a bit strange now isn't it? See this example: https://jsfiddle.net/yjhq836o/ It's the same as your recent example, but using the same |
I see no difference between the current version and my PR. My PR should change rendering top xAxis labels only, all other axes should remain unchanged |
@pawelfus OK fair enough, in which case it seems like a big improvement 👍... but is a fix also required for the bottom xAxis labels, in that case? |
I might be missing something, but in the top labels, the problem was with the unpredictable height of the labels, right? As a result of this issue, using As for the bottom xAxis. default |
@pawelfus maybe I'm missing something myself, but my understanding is that the effect of But for the bottom xAxis this is what we see for ... and this is what we see for So for the bottom xAxis, the But for the top xAxis, the So why does |
@pawelfus it's looking pretty good so far! There's still a problem I'm struggling with though, and it may or may not be related to this particular issue, but in any case I wonder whether you had some insight: https://jsfiddle.net/mt7fbkpy/ In the above example, the third argument to your If you look across each row (font size increasing) you can see that the gap between the labels and the xAxis is increasing, and the gap between the labels and the title is decreasing: Ideally I'd like the axis labels to be positioned with vertical gaps above/below that are constant, or at least consistent (i.e. both increasing/decreasing with font size at the same rate)... in my use case the font size is variable and therefore it needs to look right regardless of font size. At the moment the only way I can see to make positioning consistent across different font sizes is to add a horrible correction to https://jsfiddle.net/492hwqxj/ It looks a little better, but is there a way to make this positioning better, out of the box? |
@pawelfus just wondering if you have any thoughts on my last couple of comments? |
Hi @drmrbrewer, sorry for the late reply. The y offset doesn't take the font size into consideration because the labels have CSS styles without |
@raf18seb so it was literally just a case of adding |
It looks like that's the case :) |
The margins and positioning of the axis labels are now behaving really well, and consistently... thanks for the fix @pawelfus :) |
@raf18seb is there any way to change things so that the y offset does take the font size into consideration, even without It's possible I can work around it but I thought I'd just check if there was any way that the core highcharts could position the labels more accurately in this situation even without |
@drmrbrewer, unfortunately, you're setting the different CSS I'd also go for the |
Take the following example:
https://jsfiddle.net/8wvkstxh/1/
The chart options include a
y
adjustment to the topxAxis
labels, because, without it, the labels are too far from the axis itself (for my liking):https://jsfiddle.net/8wvkstxh/2/
But with the
y
adjustment included (first example above), there is now a lot of dead space above the top x axis labels (I'm trying to create a chart layout which minimises dead margin space and maximises chart area, so I'm sensitive to this).The top margin is seemingly "correct" for the default y position (without the y adjustment -- second example above), in that there is only a small gap between the labels and the edge.
But with the adjusted y position there is too much margin space.
It seems to me that the problem is that in order to set the y position to my liking (to move the labels down from their default position), I need a negative value for y.
But a negative y value actually should normally be pushing the labels up... so it seems that highcharts is thinking that more margin space will be required, and adds margin space to compensate for this, even though the labels are actually lower than without the negative adjustment (so that the opposite should have happened... the top margin should have been reduced, not increased).
Compare this with setting y explicitly to
0
:https://jsfiddle.net/sw36dqtp/
Therein lies the problem: setting
y: 0
gives a very different result to not settingy
at all. I need to sety
to get the y position right, so I need to state a value, and I'm moving it up fromy: 0
so I need to specify a negative value, which highcharts is apparently compensating for by adding more margin space which isn't needed. This leaves a lot of bloat in the top margin.The text was updated successfully, but these errors were encountered: