Download & Extend

Styling Results as a chart

Project:Decisions
Version:6.x-1.x-dev
Component:Documentation
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Am looking to use this module and was wondering if it is possible to style the output. I have seen something similar with the polls module which use the charts api and was wondering how I would go about creating something similar to do something similar with decisiions?

http://drupal.org/node/404840ons selection.

namely

OK carrying on from before, put this in your template.php file (don't forget to change mytheme to your theme name)

function mytheme_preprocess_poll_results(&$variables) {
  //theme the poll results block

  $html = $variables['results'];
  $pattern = "@class=\"text\"\>(.*)\</div\>@";
  preg_match_all($pattern, $html, $choices); //extract choices
  $pattern = "@style=\"width: (.*)%;\"@";
  preg_match_all($pattern, $html, $votes); //extract percentages

  $chart = array(
    '#chart_id' => 'poll_chart',
    '#type' => CHART_TYPE_PIE_3D,
  );
// NEED TO FILL IN DATA TO MAKE CHART
  for ($c=0; $c < count($choices[1]); $c++) { //make labels and values
     $chart['#data'][$choices[1][$c]] = $votes[1][$c]; //number of votes
     $chart['#legends'][] = $choices[1][$c] . " (" . $votes[1][$c] . "%)"; // labels
  }
  $variables['results'] = chart_render($chart); //render graph
}
copy the poll-results-block.tpl.php to your template folder and make it something like

<div class="poll">
  <h3 class="title"><?php print $title ?></h3>
  <?php print $results ?>
</div>
And now your results block should contain the graph.
nobody click here