public function Google::preRender in Charts 5.0.x
Same name and namespace in other branches
- 8.4 modules/charts_google/src/Plugin/chart/Library/Google.php \Drupal\charts_google\Plugin\chart\Library\Google::preRender()
Pre render.
Parameters
array $element: The element.
Return value
array The chart element.
Overrides ChartInterface::preRender
File
- modules/
charts_google/ src/ Plugin/ chart/ Library/ Google.php, line 44
Class
- Define a concrete class for a Chart.
Namespace
Drupal\charts_google\Plugin\chart\LibraryCode
public function preRender(array $element) {
$chart_definition = [];
// Convert the chart renderable to a proper definition.
$chart_definition['visualization'] = $this
->chartsGoogleVisualizationType($element['#chart_type']);
$chart_definition = $this
->chartsGooglePopulateChartOptions($element, $chart_definition);
$chart_definition = $this
->chartsGooglePopulateChartAxes($element, $chart_definition);
$chart_definition = $this
->chartsGooglePopulateChartData($element, $chart_definition);
if (!isset($element['#id'])) {
$element['#id'] = Html::getUniqueId('google-chart-render');
}
// Trim out empty options.
ChartElement::trimArray($chart_definition['options']);
$element['#attached']['library'][] = 'charts_google/google';
$element['#attributes']['class'][] = 'charts-google';
$element['#chart_definition'] = $chart_definition;
return $element;
}