Hey, this is a cool idea. I recently reworked the axis-label code for
time axes, in some sort of attempt to ensure there were never too many
(or too few) labels. But my decisions were based purely on the ranges
of data points, not on the space physically available (which changes
depending on how small or large you render the whole layout).
Automatically eliding labels that overlap makes the chart look slicker
at all sizes. This may even permit the existing code in Graphics/
Rendering/Chart/Axis/LocalTime.hs to become a bit freer in assigning
more labels, confident in the knowledge that renderAxis will will tidy
up any resulting clutter.
> 3) I'm not confident in my implementations of yBounds. I'm treating
> VTA_BaseLine as equivalent to VTA_Bottom, which I expect is wrong.
I think you probably want to use the properties "fontExtentsAscent"
etc, as in the code for drawTextR nearby:
yadj VTA_Top te fe = C.fontExtentsAscent fe
yadj VTA_Centre te fe = - (C.textExtentsYbearing te) / 2
yadj VTA_BaseLine te fe = 0
yadj VTA_Bottom te fe = -(C.fontExtentsDescent fe)
Regards,
Malcolm
Hey, this is a cool idea.
I recently reworked the axis-label code for time axes, in some sort of attempt to ensure there were never too many (or too few) labels.
I think you probably want to use the properties "fontExtentsAscent" etc, as in the code for drawTextR nearby:
I wonder if it might look better if it worked such that labels were
hidden consistently across the axis, rather than testing each one as we
draw them. ie we first consider all the labels, and if there are no
overlaps, draw them. If there are overlaps, then consider taking just
every second label. If that still has overlaps, take every third label, etc.
Tim
I wonder if it might look better if it worked such that labels were hidden consistently across the axis, rather than testing each one as we draw them. ie we first consider all the labels, and if there are no overlaps, draw them. If there are overlaps, then consider taking just every second label. If that still has overlaps, take every third label, etc.
This does seem like a better way. Here's another patch that implements it, and also prevents overlapping axis_context_ labels.I wonder if it might look better if it worked such that labels were hidden consistently across the axis, rather than testing each one as we draw them. ie we first consider all the labels, and if there are no overlaps, draw them. If there are overlaps, then consider taking just every second label. If that still has overlaps, take every third label, etc.
Also included is a new attempt to prevent the labels from being too close to each other, by requiring some horizontal buffer between them. Any ideas how best to set a reasonable buffer size for variable graph and label sizes? As a start I'm simply extending each label's draw rectangle by 50%. It looks nice for my example, but the labels are all pretty much the same width. Perhaps a buffer based on the average label width would be better?