The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Imager::Chart::Radial

SYNOPSIS

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

DESCRIPTION

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

ABOUT

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.

USING

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

$chart->plot_axis();

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,
                             "Layout"=>8,"Navigation"=>8,"Organisation"=>8,"Searching"=>7,
                             },
                     },
                     { Label => "Baz", Colour => "green", Values => {
                         "Reliability"=>7,"Ease of Use"=>2,"Response Speed"=>9,"Information"=>8,
                         "Layout"=>3,"Navigation"=>4,"Organisation"=>6,"Searching"=>3,
                         },
                    },
            );

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.

$chart->add_legend();

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.

$chart->print('newchart.png');

SEE ALSO

Imager

Imager::Font

GD

GD::Graph

AUTHOR

Aaron J Trevena <aaron@droogs.org>

COPYRIGHT

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'