function _charts_google_populate_chart_axes in Charts 7.2
Same name and namespace in other branches
- 8 modules/charts_google/charts_google.inc \_charts_google_populate_chart_axes()
Utility to populate chart axes.
1 call to _charts_google_populate_chart_axes()
- _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 104 - Callbacks and utility functions for rendering a Google Chart.
Code
function _charts_google_populate_chart_axes($chart, $chart_definition) {
foreach (element_children($chart) as $key) {
if ($chart[$key]['#type'] === 'chart_xaxis' || $chart[$key]['#type'] === 'chart_yaxis') {
// Make sure defaults are loaded.
if (empty($chart[$key]['#defaults_loaded'])) {
$chart[$key] += element_info($chart[$key]['#type']);
}
// Populate the chart data.
$axis = array();
$axis['title'] = $chart[$key]['#title'] ? $chart[$key]['#title'] : '';
$axis['titleTextStyle']['color'] = $chart[$key]['#title_color'];
$axis['titleTextStyle']['bold'] = $chart[$key]['#title_font_weight'] === 'bold' ? TRUE : FALSE;
$axis['titleTextStyle']['italic'] = $chart[$key]['#title_font_style'] === 'italic' ? TRUE : FALSE;
$axis['titleTextStyle']['fontSize'] = $chart[$key]['#title_font_size'];
// In Google, the row column of data is used as labels.
if ($chart[$key]['#labels'] && $chart[$key]['#type'] === 'chart_xaxis') {
foreach ($chart[$key]['#labels'] as $label_key => $label) {
$chart_definition['data'][$label_key + 1][0] = $label;
}
}
$axis['textStyle']['color'] = $chart[$key]['#labels_color'];
$axis['textStyle']['bold'] = $chart[$key]['#labels_font_weight'] === 'bold' ? TRUE : FALSE;
$axis['textStyle']['italic'] = $chart[$key]['#labels_font_style'] === 'italic' ? TRUE : FALSE;
$axis['textStyle']['fontSize'] = $chart[$key]['#labels_font_size'];
$axis['slantedText'] = !empty($chart[$key]['#labels_rotation']) ? TRUE : NULL;
$axis['slantedTextAngle'] = $chart[$key]['#labels_rotation'];
$axis['gridlines']['color'] = $chart[$key]['#grid_line_color'];
$axis['baselineColor'] = $chart[$key]['#base_line_color'];
$axis['minorGridlines']['color'] = $chart[$key]['#minor_grid_line_color'];
$axis['viewWindowMode'] = isset($chart[$key]['#max']) ? 'explicit' : NULL;
$axis['viewWindow']['max'] = strlen($chart[$key]['#max']) ? (int) $chart[$key]['#max'] : NULL;
$axis['viewWindow']['min'] = strlen($chart[$key]['#min']) ? (int) $chart[$key]['#min'] : NULL;
// Merge in axis raw options.
if (isset($chart[$key]['#raw_options'])) {
$axis = drupal_array_merge_deep($axis, $chart[$key]['#raw_options']);
}
// Multi-axis support only applies to the major axis in Google charts.
$chart_type_info = chart_get_type($chart['#chart_type']);
$axis_index = $chart[$key]['#opposite'] ? 1 : 0;
if ($chart[$key]['#type'] === 'chart_xaxis') {
$axis_keys = !$chart_type_info['axis_inverted'] ? array(
'hAxis',
) : array(
'vAxes',
$axis_index,
);
}
else {
$axis_keys = !$chart_type_info['axis_inverted'] ? array(
'vAxes',
$axis_index,
) : array(
'hAxis',
);
}
$axis_drilldown =& $chart_definition['options'];
foreach ($axis_keys as $key) {
$axis_drilldown =& $axis_drilldown[$key];
}
$axis_drilldown = $axis;
}
}
return $chart_definition;
}