Google Chart API Module
I was recently asked to take some civicrm demographic data from various groups and graph the data so that a visual comparison could be made between groups. In the course of looking for some graphing/charting technique that would integrate well with drupal & civicrm I discovered the google chart api module. I decided to use it to display some nifty looking 3D pie charts with a breakdown of different group demographics where each demographic was appropriately labeled on the pie chart. The API allows one to do this pretty easily:
// Set up the chart:
$chart1[$group_name] = array('#chart_id' => $group_name .'_chart1',
'#title' => t($group_name .' - chart1'),
'#type' => CHART_TYPE_PIE_3D,
'#size' => chart_size(750, 300),
);
// Now add data & labels to the chart
while (looping through group data pulled from civicrm db) {
$country_chart[$group_name]['#data']['foo'] = $data_to_add;
$country_chart[$group_name]['#labels'][] = t($my_label);
}&chma=50,50,50,50_chart_append('chma', $chart['#margins'], $data);switch($attr) {
// Margins
case 'chma':
// Remove any whitespace from this value
// Otherwise these spaces are encoded and the margins will not work
$data[$attr] = str_replace(" ", "", $value);
break; // Set up the chart:
$chart1[$group_name] = array('#chart_id' => $group_name .'_chart1',
'#title' => t($group_name .' - chart1'),
'#type' => CHART_TYPE_PIE_3D,
'#size' => chart_size(750, 300),
'#margin' => '50, 50, 50, 50',
);



















Comments
Post new comment