cd $HOME

Patch for Gruff (large legends)

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 ;)

Back

Comments

pam (http://mouraf.org) on April 04, 2007 17:49 (477 days ago) wrote

Actually, images will be useful.

Look at the problem with "several lines":http://mouraf.org/documents/rails/sucks.png even if it works with a "single line":http://mouraf.org/documents/rails/rocks.png

Undindzet (http://www.blblakga.com) on October 31, 2007 06:16 (268 days ago) wrote

Where I can find good quality films? Can anyone help me?



The content of this field is kept private and will not be shown publicly.