public function C3::preRender in Charts 8.4
Same name and namespace in other branches
- 5.0.x modules/charts_c3/src/Plugin/chart/Library/C3.php \Drupal\charts_c3\Plugin\chart\Library\C3::preRender()
Pre render.
Parameters
array $element: The element.
Return value
array The chart element.
Overrides ChartInterface::preRender
File
- modules/
charts_c3/ src/ Plugin/ chart/ Library/ C3.php, line 43
Class
- C3
- Define a concrete class for a Chart.
Namespace
Drupal\charts_c3\Plugin\chart\LibraryCode
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-c3');
}
$chart_definition['bindto'] = '#' . $element['#id'];
$element['#attached']['library'][] = 'charts_c3/c3';
$element['#attributes']['class'][] = 'charts-c3';
$element['#chart_definition'] = $chart_definition;
return $element;
}