I'm working on a project with fellow Birmingham.pm'er and Malvern LUG head honcho, Phil, that involves some graphs. Some radial (or radar) graphs to be exact. When Phil and I were discussing some of the requirements, I mentioned that I liked playing with graphs and would look forward to having the chance to look at something that I didn't think was on CPAN, at least not that I'd noticed. On further investigation, it appears I was wrong. There were 3 modules that seemed to fit the bill.
So my first task was to evaluate the 3. The three distributions were GD::Graph::radar, GD::Chart::Radial and Imager::Chart::Radial. The test was quite disappointing, and an obvious choice stood out a mile. Both GD::Graph::radar and Imager::Chart::Radial couldn't even produce a valid image for the very simple data sets. I mean:
my ($width, $height) = (400,400); my @data = ([qw/A B C D E F/],[qw/3 3 3 3 3 3/],[qw/1 2 3 1 2 3/]);
is hardly challenging is it? Well it obviously is, as GD::Graph::radar couldn't even plot any points and Imager::Chart::Radial, although able to plot the graph, did so with a scale of 15 in a 200x200 square, with the legend left blank and the rest of the image left as empty space!
Thankfully, GD::Chart::Radial did at least display a title, a legend and quite reasonably plotted the chart. Although it didn't quite do it as it states on the tin, it was considerably closer to what either of the other two could perform. Teejay was the module author, so I decide to get in touch and let him know I planned to expand his module, and to prepare him for some patches. So over the last couple of weeks I've been working on fixing some of the minor flaws, adding tests and expanding the module to work how I wanted it to. After the latest mega patch, Aaron has handed maintenance over to me, so that I can continue to improve and expand the distribution. I'm very grateful for Aaron havig started the module, as it's saved me so much time getting the original project underway and producing graphs the way we wanted them.
The distribution now handles defaults better and allows colour specification for background and scale markings. It adds a 'Fill' style, which enables the resulting graph to be a filled polygon. The labels and points are now printed in a clockwise order (rather than hash random) starting from 12 O'Clock. One rewarding bit has been adding the tests, as I've managed to get code coverage up to 95%. There is plenty more that I'd like to add to the distribution, but I'll give the current release a chance to get some much needed CPAN testing. So the latest release (0.03) should be hitting a CPAN server near you very soon.
Re:Examples?
barbie on 2007-06-12T14:37:09
All in good time
:) There are several real world examples I can include from the project I'm doing, as well as some that will give a more broader understanding of how to get the best out of the module, so I'll include those in the next release. If you have any other suggestions for improvements, please feel free to send them my way.
Re:Examples?
hex on 2007-06-12T17:06:49
Brilliant. Thanks!Imager::Chart::Radial
TeeJay on 2007-06-12T18:12:53
I'll have a look at barbies changes to GD::Chart::Radial and try and use that to update the Imager version I wrote - they're both pretty similar internally.
Re:I HATE GD
barbie on 2007-06-13T12:55:36
When I have a little more time I might just do that. I haven't looked at postscript in a very long time, even then I wouldn't have confidently said I was able to code it. Looks like there is also a PostScript::Graph, which might be a good start too.
However, in this case I wanted something that was pretty much there, so I didn't have to spend too much time on it. The pretty side of it will come later
:)