You are here

visualization.theme.inc in Visualization API 7

Theme file for the visualization part of the module.

File

theme/visualization.theme.inc
View source
<?php

/**
 * @file
 * Theme file for the visualization part of the module.
 */

/**
 * Preprocess function for visualization function.
 *
 * Used by both regular calls to theme() and the visualization Views handler.
 */
function template_preprocess_visualization(&$vars) {
  $options = $vars['options'];
  drupal_add_library('visualization', 'visualization');
  if (!empty($vars['view'])) {
    $view = $vars['view'];

    // Fields.
    foreach ($view->field as $name => $field) {
      $options['fields'][$name]['label'] = $field->options['label'];
    }

    // Data.
    $data = $view->style_plugin->rendered_fields;
  }
  else {
    $data = $options['data'];
  }
  if (!empty($options['xAxis']['invert'])) {
    $data = array_reverse($data);
  }
  $chart_id = 'visualization_' . uniqid();
  $plugin = visualization_plugin($options['type']);
  $vars['chart'] = $plugin['handler']
    ->render($chart_id, $data, $options);
  $vars['chart_attributes'] = drupal_attributes(array(
    'id' => $chart_id,
    'class' => array(
      'visualization-chart',
      'visualization-chart-' . $plugin['name'],
    ),
  ));
  $plugin['handler']
    ->postRender();
}

Functions

Namesort descending Description
template_preprocess_visualization Preprocess function for visualization function.