You are here

public function Billboard::preRender in Charts 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/charts_billboard/src/Plugin/chart/Library/Billboard.php \Drupal\charts_billboard\Plugin\chart\Library\Billboard::preRender()

Pre render.

Parameters

array $element: The element.

Return value

array The chart element.

Overrides ChartInterface::preRender

File

modules/charts_billboard/src/Plugin/chart/Library/Billboard.php, line 43

Class

Billboard
Define a concrete class for a Chart.

Namespace

Drupal\charts_billboard\Plugin\chart\Library

Code

public function preRender(array $element) {

  // Populate chart settings.
  $chart_definition = [];
  $chart_definition = $this
    ->populateOptions($element, $chart_definition);
  $chart_definition = $this
    ->populateData($element, $chart_definition);
  $chart_definition = $this
    ->populateAxes($element, $chart_definition);
  if (!isset($element['#id'])) {
    $element['#id'] = Html::getUniqueId('chart-billboard');
  }
  $chart_definition['bindto'] = '#' . $element['#id'];
  $element['#attached']['library'][] = 'charts_billboard/billboard';
  $element['#attributes']['class'][] = 'charts-billboard charts-bb';
  $element['#chart_definition'] = $chart_definition;
  return $element;
}