Library pages

For definitive info about Google Charts library please see it's home page, it's reference page and it's parameters reference page.

Instalation

Google Charts is ready to be used, i.e., you don't have to install any extra files.

Dependency

Google Charts has no extra dependencies.

Usage

The quickest code to get something graphed using Google Charts:

<?php
function charts_graphs_test() {
  $canvas = charts_graphs_get_graph('google-charts');

  $canvas->title = 'Google Charts Chart';
  $canvas->type = 'line';
  $canvas->y_legend = 'Y Legend';
  $canvas->colour = '#808000';
  $canvas->theme = 'keynote';
  $canvas->series = array(
    'Some Value' => array(9,6,7,9,5,7,6,9,7),
    'Page Views' => array(6,7,9,5,7,6,9,7,3),
  );
  $canvas->x_labels = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');

  $out = $canvas->get_chart();

  return $out;
}

Arbitrary parameters

Google Charts implementation for Charts and Graphs supports the parameters general parameter. With it the user can set any parameter in Google Charts as everything set in it will be passed to Google Charts call and will override any default setting or setting through the standard settings supported by Charts and Graphs.

The parameters option is an array where each key is the property name and each value is the value for the same property.

This way the user has complete control on what is being included on the charting call.

With great power comes great responsability.

As the ultimate control feature the parameters option intends to be, the values are passed absolutely unchanged as defined by the user. There is no urlencoding, quotes inclusion or any other safety net. The values should be set in a safe and complete manner.

Example

Setting bar width and spacing:

<php
$canvas->parameters['chbh'] = "25,5,10";

Graph types supported

Google Charts supports all main and standardized graph types except donut. It also supports the following graph types:

pie_3d
3D pie chart.
queued_bar
Columns are positioned one behind another.

Examples

Limitations

Google Charts using GET HTTP method limits the URLs (where all graph data is sent) to 2K so you might reach this limit (and not get a proper graph) rather quickly.

It is possible to generate graphs with Google Charts formed of up to 16K of data but only through POST HTTP method. Google Charts for Charts and Graphs does not support the POST method presently. Patches are welcomed.