GD::Graph::Polar - Make polar graph using GD package
use GD::Graph::Polar; my $obj=GD::Graph::Polar->new(size=>480, radius=>100); $obj->addPoint (50=>25); $obj->addPoint_rad (50=>3.1415); $obj->addGeoPoint (75=>25); $obj->addGeoPoint_rad (75=>3.1415); $obj->addLine($r0=>$t0, $r1=>$t1); $obj->addLine_rad($r0=>$t0, $r1=>$t1); $obj->addGeoLine($r0=>$t0, $r1=>$t1); $obj->addGeoLine_rad($r0=>$t0, $r1=>$t1); $obj->addArc($r0=>$t0, $r1=>$t1); $obj->addArc_rad($r0=>$t0, $r1=>$t1); $obj->addGeoArc($r0=>$t0, $r1=>$t1); $obj->addGeoArc_rad($r0=>$t0, $r1=>$t1); $obj->addString($r=>$t, "Hello World!"); $obj->addString_rad($r=>$t, "Hello World!"); $obj->addGeoString($r=>$t, "Hello World!"); $obj->addGeoString_rad($r=>$t, "Hello World!"); $obj->font(gdSmallFont); #sets the current font from GD exports $obj->color("blue"); #sets the current color from Graphics::ColorNames $obj->color([0,0,0]); #sets the current color [red,green,blue] print $obj->draw;
This package is a wrapper arround GD to produce polar graphs with an easy interface. I use this package to display GPS satellites on a graph with data from the Net::GPSD3 package.
The new constructor.
my $obj = GD::Graph::Polar->new( #default values size => 480, #width and height in pixels radius => 1, #scale of the radius ticks => 10, #number of major ticks border => 2, #pixel border around graph rgbfile => "/usr/X11R6/lib/X11/rgb.txt" );
Method to add a point to the graph.
$obj->addPoint(50=>25);
$obj->addPoint_rad(50=>3.1415);
$obj->addGeoPoint(75=>25);
$obj->addGeoPoint_rad(75=>3.1415);
Method to add a line to the graph.
$obj->addLine(50=>25, 75=>35);
$obj->addLine_rad(50=>3.14, 75=>3.45);
$obj->addGeoLine(50=>25, 75=>35);
$obj->addGeoLine_rad(50=>3.14, 75=>3.45);
Method to add an arc to the graph.
$obj->addArc(50=>25, 75=>35);
$obj->addArc_rad(50=>3.14, 75=>3.45);
$obj->addGeoArc(50=>25, 75=>35);
$obj->addGeoArc_rad(50=>25, 75=>35);
Method to add a string to the graph.
Returns a GD object
Returns a Graphics::ColorNames object
Method to set or return the current drawing color
my $colorobj=$obj->color("blue"); #if Graphics::ColorNames available my $colorobj=$obj->color([77,82,68]); #rgb=>[decimal,decimal,decimal] my $colorobj=$obj->color;
Method to set or return the current drawing font (only needed by the very few)
use GD qw(gdGiantFont gdLargeFont gdMediumBoldFont gdSmallFont gdTinyFont); $obj->font(gdSmallFont); #the default $obj->font;
Sets or returns the width and height of the graph in pixels.
Sets or returns the radius of the Graph
Sets or returns an RGB file.
Note: This method will search in a few locations for a file.
Method returns a PNG binary blob.
my $png_binary=$obj->draw;
Please log on RT and send to the author.
DavisNetworks.com supports all Perl applications including this package.
Michael R. Davis qw/perl michaelrdavis com/
Copyright (c) 2011 Michael R. Davis (mrdvt92)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
GD, Geo::Constants, Geo::Functions, Graphics::ColorNames
To install GD::Graph::Polar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GD::Graph::Polar
CPAN shell
perl -MCPAN -e shell install GD::Graph::Polar
For more information on module installation, please visit the detailed CPAN module installation guide.