Imager::Chart::Radial
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.
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
$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, }, }, );
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.
To write out the graph just call the print method with the filename you wish to write to.
$chart->print('newchart.png');
Imager
Imager::Font
GD
GD::Graph
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:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Radial, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Radial
CPAN shell
perl -MCPAN -e shell install Radial
For more information on module installation, please visit the detailed CPAN module installation guide.