Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

barbie (2653)

barbie
  reversethis-{ku. ... m} {ta} {eibrab}
http://barbie.missbarbell.co.uk/

Leader of Birmingham.pm [pm.org] and a CPAN author [cpan.org]. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [yapc-surveys.org] and the QA Hackathon [qa-hackathon.org] websites. Also the current caretaker for the CPAN Testers websites and data stores.

If you really want to find out more, buy me a Guinness ;)

Links:
Memoirs of a Roadie [missbarbell.co.uk]
[pm.org]
CPAN Testers Reports [cpantesters.org]
YAPC Conference Surveys [yapc-surveys.org]
QA Hackathon [qa-hackathon.org]

Journal of barbie (2653)

Tuesday June 12, 2007
01:39 AM

Fun with Graphs

[ #33499 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Good work on taking the distro over. Any chance you could add some example output, a la that which comes with Chart::Strip? Judging from your description of the other radial modules I'm not likely to use either of them, but in general having examples really helps when it comes to choosing a graphics distribution.
    • 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.

    • 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.
      --

      @JAPH = qw(Hacker Perl Another Just);
      print reverse @JAPH;
  • Every time someone uses GD::* god kills a kitten. Please please please please please use PostScript (or PostScript::Simple if you can't write the stuff yourself) instead. It's a lot easier to use than GD::*, it's easier to build, and the results look better.
    • 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 :)