04.04
A common problem with Gruff is that the legend will spill off the screen and be cut off in the final image when there are
a large number of datasets.
I’ve adapted Stephen Lombardo’s patch for Gruff 0.2.8. Download it here.
Looking at the source code, the draw_legend() just calculate the width
of the legend (sum of the labels size) and append it to the x offset. The patch allows to draw the legend on multiple lines.
It works but the legend isn’t centered anymore when using several lines. You can notice the
legend_left = (@raw_columns - legend_width) / 2
+ legend_left = 20
When it doesn’t fit on one line, legend_left = 20. So, it’s not centered anymore. The solution would be to add a loop to calculate the width of the line and then reset the x offset with a new calculated legend_left.
Anyway, imagining the rendered graph, I’m not sure it would be nicer. Justifying the legend with fixed legend_left & legend_right neither.
It’s definitively a question of beauty, not an algorithmic problem
No Comment.
Add Your Comment