You are here

function _charts_google_populate_chart_options in Charts 8

Same name and namespace in other branches
  1. 7.2 modules/charts_google/charts_google.inc \_charts_google_populate_chart_options()

Utility to populate main chart options.

1 call to _charts_google_populate_chart_options()
_charts_google_render in modules/charts_google/charts_google.inc
Chart render callback; Convert all chart-level data.

File

modules/charts_google/charts_google.inc, line 61
Callbacks and utility functions for rendering a Google Chart.

Code

function _charts_google_populate_chart_options($chart, $chart_definition) {
  $chart_definition['options']['title'] = $chart['#title'] ? $chart['#title'] : NULL;
  $chart_definition['options']['titleTextStyle']['color'] = $chart['#title_color'];
  $chart_definition['options']['titleTextStyle']['bold'] = $chart['#title_font_weight'] === 'bold' ? TRUE : FALSE;
  $chart_definition['options']['titleTextStyle']['italic'] = $chart['#title_font_style'] === 'italic' ? TRUE : FALSE;
  $chart_definition['options']['titleTextStyle']['fontSize'] = $chart['#title_font_size'];
  $chart_definition['options']['titlePosition'] = $chart['#title_position'];
  $chart_definition['options']['colors'] = $chart['#colors'];
  $chart_definition['options']['fontName'] = $chart['#font'];
  $chart_definition['options']['fontSize'] = $chart['#font_size'];
  $chart_definition['options']['backgroundColor']['fill'] = $chart['#background'];
  $chart_definition['options']['isStacked'] = $chart['#stacking'] ? TRUE : FALSE;
  $chart_definition['options']['tooltip']['trigger'] = $chart['#tooltips'] ? 'focus' : 'none';
  $chart_definition['options']['tooltip']['isHtml'] = $chart['#tooltips_use_html'] ? TRUE : FALSE;
  $chart_definition['options']['pieSliceText'] = $chart['#data_labels'] ? NULL : 'none';
  $chart_definition['options']['legend']['position'] = $chart['#legend_position'] ? $chart['#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'] = $chart['#legend_title'];
  $chart_definition['options']['legend']['titleTextStyle']['bold'] = $chart['#legend_title_font_weight'] === 'bold' ? TRUE : FALSE;
  $chart_definition['options']['legend']['titleTextStyle']['italic'] = $chart['#legend_title_font_style'] === 'italic' ? TRUE : FALSE;
  $chart_definition['options']['legend']['titleTextStyle']['fontSize'] = $chart['#legend_title_font_size'];
  $chart_definition['options']['legend']['textStyle']['bold'] = $chart['#legend_font_weight'] === 'bold' ? TRUE : FALSE;
  $chart_definition['options']['legend']['textStyle']['italic'] = $chart['#legend_font_style'] === 'italic' ? TRUE : FALSE;
  $chart_definition['options']['legend']['textStyle']['fontSize'] = $chart['#legend_font_size'];
  $chart_definition['options']['width'] = $chart['#width'] ? $chart['#width'] : NULL;
  $chart_definition['options']['height'] = $chart['#height'] ? $chart['#height'] : NULL;
  $chart_definition['options']['animation']['duration'] = 10000;
  $chart_definition['options']['animation']['easing'] = 'out';
  return $chart_definition;
}