Daisuke Maki
and 1 contributors


Google::Chart - Interface to Google Charts API


  use Google::Chart;

  my $chart = Google::Chart->new(
    type => "Bar",
    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.05000 is a major rewrite, and has little to no backwards compatibility.



Creates a new Google::Chart instance.


Specifies the chart type, such as line, bar, pie, etc. If given a string like 'Bar', it will instantiate an instance of Google::Chart::Type::Bar by invoking argument-less constructor.

If you want to pass parameters to the constructor, either pass in an already instanstiated object, or pass in a hash, which will be coerced to the appropriate object

  my $chart = Google::Chart->new(
    type => Google::Chart::Bar->new(
      orientation => "horizontal"

  # or

  my $chart = Google::Chart->new(
    type => {
      module => "Bar",
      args   => {
        orientation => "horizontal"

Specifies the chart size. Strings like "400x300", hash references, or already instantiated objects can be used:

  my $chart = Google::Chart->new(
    size => "400x300",

  my $chart = Google::Chart->new(
    size => {
      width => 400,
      height => 300

Specifies the markers that go on line charts.


Specifies the axis labels and such that go on line and bar charts



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

        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

render_to_file( %args )

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.


Standardize Interface

Objects need to expect data in a standard format. This is not the case yet. (comments welcome)

Moose-ish Errors

I've been reported that some Moose-related errors occur on certain platforms. I have not been able to reproduce it myself, so if you do, please let me know.


Daisuke Maki <daisuke@endeworks.jp> (current maintainer)

Nobuo Danjou <nobuo.danjou@gmail.com>

Marcel Grünauer <marcel@cpan.org> (original author)


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

See http://www.perl.com/perl/misc/Artistic.html

1 POD Error

The following errors were encountered while parsing the POD:

Around line 267:

Expected text after =item, not a bullet