Google chart allows to create donut charts. This is just an option for the pie chart.
Check it out at https://google-developers.appspot.com/chart/interactive/docs/gallery/pie...
would be cool to have this option

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nchase created an issue. See original summary.

mcprobin’s picture

It is a bad hack and someone who maintains this should probably do it right but if you really need it ...

Inside the file charts_google.inc

and function (at line 60)

function _charts_google_populate_chart_options($chart, $chart_definition) {

Add:
$chart_definition['options']['pieHole']= $chart['#pie_hole_size'] ? $chart['#pie_hole_size'] : 0;

Then you can put in your own code:

$chart = array(
'#type' => 'chart',
'#title' => t('Example Donut Chart'),
'#chart_type' => 'pie',
'#legend_position' => 'right',
'#data_labels' => TRUE,
'#tooltips' => TRUE,
'#pie_hole_size' = 0.4
);

samuel.seide’s picture

Don't do it inside the module code, write your own custom module. Here's one I wrote that adds in piechart and some other options.

function YOURMODULENAME_chart_alter(&$chart, $chart_id) {

  $array1 = array();

  $piehole = '__donut';
  $threed = '__3d';
  $stacked = '__stacked';
  $curvedlines = '__curved';

  $pieholecheck = strpos($chart_id, $piehole);
  $threed = strpos($chart_id, $threed);
  $stackedcheck = strpos($chart_id, $stacked);
  $curvedlinescheck = strpos($chart_id, $curvedlines);

  if ($curvedlinescheck !== false) { //checks if the chart id has __curvedlines added to the machine name
    $array1 = array('curveType' => 'function');
  }
  elseif ($stackedcheck !== false) { //checks if the chart id has __stacked added to the machine name
    $array1 = array('isStacked' => 'TRUE');
  }
  elseif ($threed !== false) { //checks if the chart id has __threed added to the machine name
    $array1 = array('is3D' => 'TRUE');
  }
  elseif ($pieholecheck !== false) { //checks if the chart id has __donut added to the machine name
    $array1 = array('pieHole' => '.4');
  }

  $array2 = array(
  'chartArea' => array('width' => "60%", 'height' => "55%", 'left' => 100),
  'legend' => array('alignment' => 'center', 'maxLines' => 10, 'textStyle' => array('fontSize' => 10)),
  'hAxis' => array('maxTextLines' => 5)
  );

  $chart['#raw_options'] = $array1 + $array2;

}
sashkernel’s picture

Samuel,
Do you have your module published on Drupal site?

preethi_warrier’s picture

Assigned: Unassigned » preethi_warrier
Status: Active » Needs review
FileSize
1.48 KB

I have submitted a patch for this feature request. Please review.

preethi_warrier’s picture

preethi_warrier’s picture

Assigned: preethi_warrier » Unassigned