public function Chartjs::preRender in Charts 8.4
Same name and namespace in other branches
- 5.0.x modules/charts_chartjs/src/Plugin/chart/Library/Chartjs.php \Drupal\charts_chartjs\Plugin\chart\Library\Chartjs::preRender()
Pre render.
Parameters
array $element: The element.
Return value
array The chart element.
Overrides ChartInterface::preRender
File
- modules/
charts_chartjs/ src/ Plugin/ chart/ Library/ Chartjs.php, line 165
Class
- Chartjs
- Define a concrete class for a Chart.
Namespace
Drupal\charts_chartjs\Plugin\chart\LibraryCode
public function preRender(array $element) {
$chart_definition = [];
if (!isset($element['#id'])) {
$element['#id'] = Html::getUniqueId('chartjs-render');
}
$chart_definition = $this
->populateCategories($element, $chart_definition);
$chart_definition = $this
->populateDatasets($element, $chart_definition);
$chart_definition = $this
->populateOptions($element, $chart_definition);
$element['#attached']['library'][] = 'charts_chartjs/chartjs';
$element['#attributes']['class'][] = 'charts-chartjs';
$element['#chart_definition'] = $chart_definition;
return $element;
}