public function Google::chartsGooglePopulateChartOptions in Charts 8.4
Same name and namespace in other branches
- 5.0.x modules/charts_google/src/Plugin/chart/Library/Google.php \Drupal\charts_google\Plugin\chart\Library\Google::chartsGooglePopulateChartOptions()
Utility to populate main chart options.
Parameters
array $element: The element.
array $chart_definition: The chart definition.
Return value
array The returned chart definition.
1 call to Google::chartsGooglePopulateChartOptions()
- Google::preRender in modules/
charts_google/ src/ Plugin/ chart/ Library/ Google.php - Pre render.
File
- modules/
charts_google/ src/ Plugin/ chart/ Library/ Google.php, line 97
Class
- Define a concrete class for a Chart.
Namespace
Drupal\charts_google\Plugin\chart\LibraryCode
public function chartsGooglePopulateChartOptions(array $element, array $chart_definition) {
$chart_definition['options']['title'] = $element['#title'] ? $element['#title'] : NULL;
$chart_definition['options']['titleTextStyle']['color'] = $element['#title_color'];
$chart_definition['options']['titleTextStyle']['bold'] = $element['#title_font_weight'] === 'bold' ? TRUE : FALSE;
$chart_definition['options']['titleTextStyle']['italic'] = $element['#title_font_style'] === 'italic' ? TRUE : FALSE;
$chart_definition['options']['titleTextStyle']['fontSize'] = $element['#title_font_size'];
$chart_definition['options']['titlePosition'] = $element['#title_position'];
$chart_definition['options']['colors'] = $element['#colors'];
$chart_definition['options']['fontName'] = $element['#font'];
$chart_definition['options']['fontSize'] = $element['#font_size'];
$chart_definition['options']['backgroundColor']['fill'] = $element['#background'];
$chart_definition['options']['isStacked'] = $element['#stacking'] ? TRUE : FALSE;
$chart_definition['options']['tooltip']['trigger'] = $element['#tooltips'] ? 'focus' : 'none';
$chart_definition['options']['tooltip']['isHtml'] = $element['#tooltips_use_html'] ? TRUE : FALSE;
$chart_definition['options']['pieSliceText'] = $element['#data_labels'] ? NULL : 'none';
$chart_definition['options']['legend']['position'] = $element['#legend_position'] ? $element['#legend_position'] : 'none';
$chart_definition['options']['legend']['alignment'] = 'center';
$chart_definition['options']['interpolateNulls'] = TRUE;
// TODO: Legend title (and thus these properties) not supported by Google.
$chart_definition['options']['legend']['title'] = $element['#legend_title'];
$chart_definition['options']['legend']['titleTextStyle']['bold'] = $element['#legend_title_font_weight'] === 'bold' ? TRUE : FALSE;
$chart_definition['options']['legend']['titleTextStyle']['italic'] = $element['#legend_title_font_style'] === 'italic' ? TRUE : FALSE;
$chart_definition['options']['legend']['titleTextStyle']['fontSize'] = $element['#legend_title_font_size'];
$chart_definition['options']['legend']['textStyle']['bold'] = $element['#legend_font_weight'] === 'bold' ? TRUE : FALSE;
$chart_definition['options']['legend']['textStyle']['italic'] = $element['#legend_font_style'] === 'italic' ? TRUE : FALSE;
$chart_definition['options']['legend']['textStyle']['fontSize'] = $element['#legend_font_size'];
$chart_definition['options']['width'] = $element['#width'] ? $element['#width'] : NULL;
$chart_definition['options']['height'] = $element['#height'] ? $element['#height'] : NULL;
$chart_definition['options']['animation']['duration'] = 10000;
$chart_definition['options']['animation']['easing'] = 'out';
// Merge in chart raw options.
if (!empty($element['#raw_options'])) {
$chart_definition = NestedArray::mergeDeepArray([
$element['#raw_options'],
$chart_definition,
]);
}
return $chart_definition;
}