You are here

function _charts_highcharts_render in Charts 8

Same name and namespace in other branches
  1. 7.2 modules/charts_highcharts/charts_highcharts.inc \_charts_highcharts_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

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

1 string reference to '_charts_highcharts_render'
charts_highcharts_charts_info in modules/charts_highcharts/charts_highcharts.module
Implements hook_charts_info().

File

modules/charts_highcharts/charts_highcharts.inc, line 23
Callbacks and utility functions for rendering a Highcharts Chart.

Code

function _charts_highcharts_render($chart) {

  // Populate chart settings.
  $chart_definition = array();
  $chart_definition = _charts_highcharts_populate_chart_options($chart, $chart_definition);
  $chart_definition = _charts_highcharts_populate_chart_axes($chart, $chart_definition);
  $chart_definition = _charts_highcharts_populate_chart_data($chart, $chart_definition);

  // Remove machine names from series. Highcharts series must be an array.
  $series = array_values($chart_definition['series']);
  unset($chart_definition['series']);

  // Trim out empty options (excluding "series" for efficiency).
  charts_trim_array($chart_definition);

  // Put back the data.
  $chart_definition['series'] = $series;
  if (!isset($chart['#id'])) {
    $chart['#id'] = Html::getUniqueId('highchart-render');
  }
  $chart['#attached']['library'][] = array(
    'charts_highcharts',
    'charts_highcharts',
  );
  $chart['#attributes']['class'][] = 'charts-highchart';
  $chart['#chart_definition'] = $chart_definition;
  return $chart;
}