You are here

function _charts_example in Charts 6

Same name and namespace in other branches
  1. 7 charts.admin.inc \_charts_example()

Generate a generic chart example

Parameters

$data: Array (optional). Chart data, following the Charts Schema

Return value

HTML. The generic Chart example

1 call to _charts_example()
_charts_settings_form in ./charts.admin.inc
Module settings page. Users can set the default layout of their charts.

File

./charts.admin.inc, line 78
@author Bruno Massa http://drupal.org/user/67164

Code

function _charts_example($type, $name) {
  $data = array(
    '#title' => t('Testing Chart: !name', array(
      '!name' => $name,
    )),
    '#type' => $type,
  );

  // This will hold the example chart
  // Since the chart is an example, we should provide
  // and example data.
  $data[] = array(
    '#legend' => 'Profit',
    array(
      '#value' => 35,
      '#label' => t('Jan'),
    ),
    array(
      '#value' => 25,
      '#label' => t('Feb'),
    ),
    array(
      '#value' => 75,
      '#label' => t('Mar'),
    ),
    array(
      '#value' => 50,
      '#label' => t('Apr'),
    ),
    array(
      '#value' => 23,
      '#label' => t('May'),
    ),
    array(
      '#value' => 12,
      '#label' => t('Jun'),
    ),
  );
  $data[] = array(
    '#legend' => 'Revenue',
    10,
    20,
    55,
    72,
    45,
    50,
  );
  return charts_chart($data);
}