Google::Chart - Interface to Google Charts API
use Google::Chart; my $chart = Google::Chart->create( Bar => ( bar_space => 20, bar_width => 10, group_space => 5, orientation => 'horizontal' size => "400x300", stacked => 1, ) ); $chart->add_axis( location => 'x', label => [ qw(foo bar baz) ], ); $chart->add_dataset( color => 'FF0000', data => [ 1, 2, 3, 4, 5 ], ); print $chart->as_uri, "\n"; # or simply print $chart, "\n" $chart->render_to_file( filename => 'filename.png' );
Google::Chart provides a Perl Interface to Google Charts API (http://code.google.com/apis/chart/).
Please note that version 0.10000 is a major rewrite, and has little to no backwards compatibility.
Creates a new chart of type $chart_type. The rest of the arguments are passed to the constructor of the appropriate $chart_type class. Each chart type may have a different set of attributes that it can initialize, but the following are common to all chrats:
Specifies the chart width and height.
Strings like "400x300" are converted to their respective width and height
my $chart = Google::Chart->new( size => "400x300", );
Other parameters differ depending on the chart type.
Creates a new Google::Chart instance. You should be using
create unless you're hacking on a new chart type.
Returns the URI that represents the chart object.
Generates the chart image, and returns the contents. This method internally uses LWP::UserAgent. If you want to customize LWP settings, create an instance of LWP::UserAgent and pass it in the constructor
Google::Chart->new( ...., ua => LWP::UserAgent->new( %your_args ) );
Proxy settings are automatically read via LWP::UserAgent->env_proxy(), unless you specify GOOGLE_CHART_ENV_PROXY environment variable to 0
Generates the chart, and writes the contents out to the file specified by `filename' parameter
The base URI for Google Chart
We don't believe that we fully utilize Google Chart's abilities. So there might be things missing, things that should be changed for easier use. If you find any such case, PLEASE LET US KNOW! Suggestions are welcome, but code snippets, pseudocode, or even better, test cases, are most welcome.
I've taken Google::Chart and challenged myself to implement every example in the developer's manual (the japanese version, anyway). Unfortunately there are a handful of examples that don't render /exactly/ the way it's in the documents.
You can check which ones are failing in the included "samples.html", and send us patches ;)
<email@example.com> (current maintainer)
<firstname.lastname@example.org> (original author)
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.