Hacking on a new rule-QA subsystem for SpamAssassin, I came across this bug in GD::Graph. If:
- you are drawing a graph using GD::Graph;
- outputting in PNG or GIF format;
- and the 'box' area -- the margins outside the graph -- keeps coming up as black, instead of white as you've specified;
check your code for calls to GD::Image->trueColor(1);, or the third argument to the GD::Image->new() constructor being 1. It appears that there's a bug in the current version of GD (or GD::Graph) where graphing to a true-colour buffer is concerned, in that the 'box' area continually comes out in black.
- Test script (requires GD, GD::Graph)
- Demo PNG with trueColor set to 1
- Demo PNG with trueColor set to 0
(Seen in versions: perl 5.8.7, GD 2.23, GD::Graph 1.43 on Linux ix86; perl 5.8.6, GD 2.28, GD::Graph 1.43 on Solaris 5.10.)
reported as: http://rt.cpan.org/NoAuth/Bug.html?id=15374
It is certainly due to a non filled background, with palette images, the first color allocated will be the bgd color (ie white). With truecolor images, it is alway black (0x0) and you have to fill the image.
--Pierre
hi Pierre --
I thought it may be that, too. It's still a bug in GD::Graph in that case, anyway, since it occurs even if 'boxclr' is set to white.
Also, if you're using GD::Graph, you cannot fill the image before GD::Graph draws the graph into it with $gd->plot() anyway, as far as I know?
does $graph->gd() still exist?
It returns the GD::Image object that is going to be used to draw on. You can call it before or after plot(), if it called before, you are responsible for both bgd and transparent colors.
Yep, it does (and it's good to know that's doable). However, that's still just a workaround rather than a bug fix ;)
The easy fix (which will appear in the next version, hopefully this weekend) is to just make it always produce a palette-based image, ignoring the global setting for GD. This presumes that 256 colors ought to be enough for anybody, which sounds intrinsically hazardous but probably won't bite me in the too immediate future.
After the bug backlog is cleared, though, I could patch it up so that true-color graphs were a realistic option--does that sound like an option with real-world uses, or would it be a waste of time?
fouund this log while looking for help online re GD::GRAPH
per the documentation there's a known bug: "GD::Graph objects cannot be reused. To create a new plot, you have to create a new GD::Graph object."
How does one go about creating multiple charts?