The last few days I’ve been playing with Google’s Chart API. It’s much simpler than their other APIs. This is pretty close to dirt simple. My only “complaint” is that a lot of the variable names are a bit obscure. I’m unlikely to remember that chxl means chart axis labels. So I started writing a little class to help.
$chart = new googleChart($data, $title, $width, $height)
data should be an associative array
- your keys become the x axis
- your values become the y axis
title, width, and height are optional
$chart->title = ‘This is my title!’;
$chart->width = 400;
$chart->height = 400;
color is the color of the line
it must be a hex code
$chart->color = ‘ff8800′;
fill is the color of the space under the line
it must be a hex code
$chart->fill = ‘ffff80′;
then all you have to do is call
$url = $chart->getURL();
You can check out my “alpha release” here.