You are here

function _charts_google_render in Charts 8

Same name and namespace in other branches
  1. 7.2 modules/charts_google/charts_google.inc \_charts_google_render()

Chart render callback; Convert all chart-level data.

This essentially is an additional #pre_render callback. It operates in the same way and is simply called as part of the normal #pre_render process.

Parameters

array $chart: The chart renderable.

Return value

The modified chart renderable, with necessary #attached, #theme, and similar properties prepared for rendering.

1 string reference to '_charts_google_render'
charts_google_charts_info in modules/charts_google/charts_google.module
Implements hook_charts_info().

File

modules/charts_google/charts_google.inc, line 21
Callbacks and utility functions for rendering a Google Chart.

Code

function _charts_google_render($chart) {

  // Convert the chart renderable to a proper definition.
  $chart_definition['visualization'] = _charts_google_visualization_type($chart['#chart_type']);
  $chart_definition = _charts_google_populate_chart_options($chart, $chart_definition);
  $chart_definition = _charts_google_populate_chart_axes($chart, $chart_definition);
  $chart_definition = _charts_google_populate_chart_data($chart, $chart_definition);
  if (!isset($chart['#id'])) {
    $chart['#id'] = drupal_html_id('google-chart-render');
  }

  // Trim out empty options.
  charts_trim_array($chart_definition['options']);
  $chart['#attached']['library'][] = array(
    'charts_google',
    'charts_google',
  );
  $chart['#attributes']['class'][] = 'charts-google';
  $chart['#chart_definition'] = $chart_definition;
  return $chart;
}