Categories
PHP

Google Charts API – PHP Class

This class can embed charts in a Web page with Google Charts API.

It can generate HTML and JavaScript to make calls to the Google Charts API to display several types of charts in a Web page.

Currently it supports embedding charts of type pie, column, area, line, bar, bubble, geographic markers and gauge.

Download at phpclasses.org

Simple example:


PHP code:

$os_example = array(
	array(
		'date'		=> '2011-10',
		'WinXP'		=> '37.91',
		'Win7'		=> '40.5',
		'WinVista'	=> '11.18',
		'MacOSX'	=> '7.18',
		'iOS'		=> '1.12',
		'Other'		=> '1.42',
	),
	array(
		'date'		=> '2011-11',
		'WinXP'		=> '36.44',
		'Win7'		=> '41.13',
		'WinVista'	=> '11.12',
		'MacOSX'	=> '7.05',
		'iOS'		=> '1.24',
		'Other'		=> '1.56',
	),
	array(
		'date'		=> '2011-12',
		'WinXP'		=> '34.78',
		'Win7'		=> '42.65',
		'WinVista'	=> '10.88',
		'MacOSX'	=> '7.01',
		'iOS'		=> '1.41',
		'Other'		=> '1.62',
	),
	array(
		'date'		=> '2012-01',
		'WinXP'		=> '34.04',
		'Win7'		=> '44.07',
		'WinVista'	=> '10.45',
		'MacOSX'	=> '7.33',
		'iOS'		=> '1.71',
		'Other'		=> '1.66',
	),
	array(
		'date'		=> '2012-02',
		'WinXP'		=> '34.04',
		'Win7'		=> '45.23',
		'WinVista'	=> '9.87',
		'MacOSX'	=> '7.41',
		'iOS'		=> '1.81',
		'Other'		=> '1.63',
	),
	array(
		'date'		=> '2012-03',
		'WinXP'		=> '33.49',
		'Win7'		=> '46.48',
		'WinVista'	=> '9.05',
		'MacOSX'	=> '7.32',
		'iOS'		=> '1.89',
		'Other'		=> '1.77',
	),

);
echo Chart::line($os_example,array('title'=>'OS stats','height'=>600,'width'=>600));