function hook_draw_chart_alter

cis7 google_chart_tools.api.php hook_draw_chart_alter(&$settings)

Implements hook_draw_chart_alter().

1 function implements hook_draw_chart_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

cis_helper_draw_chart_alter in profiles/cis/modules/custom/cis_helper/cis_helper.module
Implements hook_draw_chart_alter().
1 invocation of hook_draw_chart_alter()
draw_chart in sites/all/modules/local_contrib/google_chart_tools/google_chart_tools.module
Draw the chart

File

sites/all/modules/local_contrib/google_chart_tools/google_chart_tools.api.php, line 10
Google Chart Tools API definitions.

Code

function hook_draw_chart_alter(&$settings) {
  foreach ($settings as $chart) {
    if (isset($chart['chart']['chartCategory']) && !empty($chart['chart']['chartCategory'])) {
      // Geting the count result by vocabulary machine name.
      $voc = taxonomy_vocabulary_machine_name_load('categories');
      $tree = taxonomy_get_tree($voc->vid);
      $header = array();
      foreach ($tree as $term) {
        // Feeds the header with terms names.
        $header[] = $term->name;
        $query = db_select('taxonomy_index', 'ti');
        $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
        // Feeding the terms with the node count.
        $terms[] = $query->countQuery()->execute()->fetchField();
      }
      $columns = array('Content per category');
      $rows = array($terms);
      // Replacing the data of the chart.
      $chart['chart']['chartCategory']['header'] = $header;
      $chart['chart']['chartCategory']['rows'] = $rows;
      $chart['chart']['chartCategory']['columns'] = $columns;
      // Adding a colors attribute to the pie.
      $chart['chart']['chartCategory']['options']['colors'] = array('red', '#004411');
    }
  }
}