Aaron James Trevena




use Imager::Chart::Radial;
my $chart = Radial->new(axis => \@axis, fonts => \%fonts);
$chart->plot_values( \@records );>
$chart->add_title("This is a chart, there are many like it but this is mine");>


This module uses Imager to plot and output Radial or Radar charts.


I originally wrote a radial chart creator based on GD, but the GD library did not provide anti-aliasing and sufficient colours for a clean looking image until relatively recently. I wrote this version because I wanted to learn Imager and also provide some charting modules for Imager to make life easier when the GD library is not available.


Creating a class

To create a new Radial object use the new method on the class

my $chart = Radial->new(axis => \@axis, fonts => \%fonts);

This requires two data structures, one for your axis and one for the fonts you wish to use:

 my %fonts = (
             text => Imager::Font->new(file  => '/path/to/fonts/cour.ttf', size  => 8),
             header => Imager::Font->new(file  => '/path/to/fonts/arial.ttf', size  => 18),
             label => Imager::Font->new(file  => '/path/to/fonts/arial.ttf', size  => 14),

Fonts must be TrueType compatible fonts, for more information see Imager::Font.

 my @axis    = (
                { Label => "Reliability" },
                { Label => "Ease of Use" },
                { Label => "Information" },
                { Label => "Layout" },
                { Label => "Navigation" },
                { Label => "Searching" },

The axis are labelled as above and provide the skeleton of the graph

Plotting the graph


This plots the axis onto the chart

$chart->plot_values( \@records );

This plots the values themselves onto the chart using the records data structure as below :

 my @records = (
                     { Label => "Foo", Colour => "red", Values => {
                             "Reliability"=>5,"Ease of Use"=>3, "Response Speed"=>6,"Information"=>4,
                             "Layout"=>3,"Navigation"=>6,"Organisation"=>7,"Searching"=>8, },
                     { Label => "Bar", Colour => "blue", Values => {
                             "Reliability"=>9,"Ease of Use"=>8,"Response Speed"=>4,"Information"=>5,
                     { Label => "Baz", Colour => "green", Values => {
                         "Reliability"=>7,"Ease of Use"=>2,"Response Speed"=>9,"Information"=>8,

Labelling the graph

You can add a title and a legend to the chart using add_title and add_legend

$chart->add_title("This is a radial chart using Imager and my own values");

The title should be short and uses the font specified as header in the fonts hash.


The legend is generated from the records, you must therefore plot the graph before adding the legend. The legend uses the label font.

Outputing the graph

To write out the graph just call the print method with the filename you wish to write to.








Aaron J Trevena <aaron@droogs.org>


Copyright (C) 2003, Aaron Trevena

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 302:

'=item' outside of any '=over'

Around line 316:

You forgot a '=back' before '=head1'