Display webform results data in a Google Chart I'm trying to display webform results as Google Charts. I'm doing this on the theme layer by overriding theme_webform_results_analysis() on my theme's template.php file and using the Chart module. Drupal 6.22, Webform 6.x-3.11.

The webform analysis page normally shows the data in a table, so I'm trying to hack apart the arrays for that table to pass stuff into the Chart API.

EDIT: I figured out how to use var_dump and found that the better approach might be to get up in the $row_data and $questions arrays separately (instead of using the $rows array that I had in the first version of this question, which was a mashup of both arrays).

EDIT #2: I think I've discovered how to grab each piece of the original $questions and $row_data arrays (see below - the foreach in the other foreach). So now I need to get those pieces into proper arrays (1 per question) and find a way to iterate through all of those.

Here's what I've got in template.php:

/**
 * Output the content of the Analysis page.
 * @see webform_results_analysis()
 */
function mytheme_webform_results_analysis($node, $data, $sids = array(), $analysis_component = NULL) {

  foreach ($data as $cid =&gt; $row_data) {

    if (is_array($row_data)) {

      // get the questions, put them in an array
      $questions = array();
      $questions[] = array('data' =&gt; check_plain($node-&gt;webform['components'][$cid]['name']));

      // this will print everything out in the right order - it really needs to
      // make an array for each question that looks like $test_chart below
      foreach ($questions as $question) {
        print $question['data'] . '&lt;br /&gt;'; // questions 
        foreach ($row_data as $key =&gt; $value) {
          print $value[0] . '&lt;br /&gt;'; // labels
          print $value[1] . '&lt;br /&gt;'; // results 
        }
      }

      // Set up the chart
      $chart = array(
        '#chart_id' =&gt; 'webform_analysis',
        '#type' =&gt; CHART_TYPE_PIE_3D,
        '#size' =&gt; chart_size(658, 250)
      );

      // not real data here, this just shows the format I'm shooting for
      $test_chart = array(
        'option 1' =&gt; '12',
        'option 2' =&gt; '45',
        'option 3' =&gt; '122'
      ); 

      // separate the above array into labels and values, add a percentage to the label
      foreach ($test_chart as $key =&gt; $value) {
        $chart['#data'][] = $test_chart[$key];
        $chart['#labels'][] = strip_tags($key) . ' (' . round($test_chart[$key], 2) .  '%)';
      }
      // pick some colors
      $chart['#data_colors'][] = 'b0c73d';
      $chart['#data_colors'][] = '667323';
      $chart['#data_colors'][] = '221f1f';

      $output = chart_render($chart);    
    }
  }

  if (count($row_data) == 0) {
    $output = t('There are no submissions for this form.');
  }

  // return the data that goes into chart function, just for testing
  // return $chart_data; 

  // someday, this might return a set of webform charts. right now it returns the fake test chart
  // return $output;
}
There is another Drupal charts module that provides support for webforms: http://drupal.org/project/fusioncharts

Fusionchart has a little sub-module called fusioncharts_webform