The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Google::Chart - Interface to Google Charts API

SYNOPSIS

  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' );

DESCRITPION

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.

METHODS

create( $chart_type => %args )

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:

width, height

Specifies the chart width and height.

size (deprecated)

Strings like "400x300" are converted to their respective width and height

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

Other parameters differ depending on the chart type.

new(%args)

Creates a new Google::Chart instance. You should be using create unless you're hacking on a new chart type.

as_uri()

Returns the URI that represents the chart object.

render()

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

render_to_file( %args )

Generates the chart, and writes the contents out to the file specified by `filename' parameter

BASE_URI

The base URI for Google Chart

FEEDBACK

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.

TODO

Coverage

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 ;)

AUTHORS

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

Nobuo Danjou <nobuo.danjou@gmail.com>

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

LICENSE

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 303:

Non-ASCII character seen before =encoding in 'Grünauer'. Assuming UTF-8