Download the latest version package from this link - http://code.google.com/p/googchart/
Step 1:
Include the API class file in the PHP file where you want to Display the Chart
include( 'GoogChart.class.php' );
Step 2:
Assign the datas which should be charted in the array variable say $data like below
$data = array(
'IE7' => 22,
'IE6' => 30.7,
'IE5' => 1.7,
'Firefox' => 36.5,
'Mozilla' => 1.1,
'Safari' => 2,
'Opera' => 1.4,
);
Set the Graph Color of your choice here in a array variable called $color
// Set graph colors
$color = array(
'#99C754',
'#54C7C5',
'#999999',
);
Step 3:
Finally building the Chart and printing it.
$chart->setChartAttrs( array(
'type' => 'pie',
'title' => 'Browser market 2008',
'data' => $data,
'size' => array( 400, 300 ),
'color' => $color
));
// Print chart
echo $chart;
Output:
Supported types:
- Pie
Standard pie chart - Line
Standard Line chart - Sparkline
Almost identical to Line, except defaults to no axis lines. - Bar-horizontal
Horizontal bar chart - Bar-vertical
Vertical bar chart
Enjoy!
No comments:
Post a Comment