You are here

function _charts_examples_combo in Charts 7.2

File

includes/charts.examples.inc, line 207

Code

function _charts_examples_combo() {
  $chart = array(
    '#type' => 'chart',
    '#chart_type' => 'column',
    '#title' => t('Combo'),
    '#legend_position' => 'bottom',
  );
  $chart['male'] = array(
    '#type' => 'chart_data',
    '#title' => t('Male'),
    '#data' => array(
      10,
      20,
      30,
    ),
    '#suffix' => 'lbs',
  );
  $chart['female'] = array(
    '#type' => 'chart_data',
    '#title' => t('Female'),
    '#data' => array(
      12,
      22,
      32,
    ),
    '#suffix' => 'lbs',
  );
  $chart['female'][0] = array(
    '#type' => 'chart_data_item',
    '#title' => t('Special title'),
    '#color' => 'red',
    '#data' => 22,
  );
  $secondary_color = '#B617E5';
  $chart['line'] = array(
    '#type' => 'chart_data',
    '#chart_type' => 'line',
    '#data' => array(
      7,
      44,
      100,
    ),
    '#title' => t('Average'),
    '#target_axis' => 'yaxis2',
    '#color' => $secondary_color,
    //'#marker_radius' => 10,
    '#prefix' => '$',
  );
  $chart['line'][1] = array(
    '#type' => 'chart_data_item',
  );
  $chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
    '#labels' => array(
      'Jan',
      'Feb',
      'Mar',
    ),
  );
  $chart['yaxis'] = array(
    '#type' => 'chart_yaxis',
    '#axis_type' => 'linear',
  );
  $chart['yaxis2'] = array(
    '#type' => 'chart_yaxis',
    '#axis_type' => 'linear',
    '#opposite' => TRUE,
    '#title' => t('Avg'),
    '#labels_color' => $secondary_color,
    '#title_color' => $secondary_color,
  );
  $example['chart'] = $chart;
  $example['notes']['google'] = t('Google charts cannot provide a legend on the same side as an axis, so legends cannot be displayed on the left or right in a combo chart.') . ' ' . t('Google cannot assign a color to an individual item. See this <a href="https://code.google.com/p/google-visualization-api-issues/issues/detail?id=1267">feature request</a>.');
  return $example;
}