You are here

function charts_graphs_test in Charts and Graphs 7

Same name and namespace in other branches
  1. 6.2 charts_graphs.module \charts_graphs_test()
  2. 6 charts_graphs.module \charts_graphs_test()
  3. 7.2 charts_graphs.module \charts_graphs_test()

For testing and Advanced Help examples.

Return value

<string>

1 string reference to 'charts_graphs_test'
charts_graphs_menu in ./charts_graphs.module
Implements hook_menu().

File

./charts_graphs.module, line 115

Code

function charts_graphs_test($submodule = NULL, $type = 'bar', $title = 'The Title', $series = NULL, $labels = NULL) {
  if ($submodule === NULL) {
    $submodule = array_shift(array_keys(charts_graphs_apis()));
  }
  if ($series === NULL) {
    $series = array(
      'Some Value' => array(
        91,
        60,
        70,
        90,
        5,
        72,
        63,
        9,
        72,
      ),
      'Page Views' => array(
        63,
        70,
        94,
        50,
        7,
        62,
        93,
        71,
        3,
      ),
    );
  }
  else {
    $series = unserialize($series);
  }
  if ($labels === NULL) {
    $labels = array(
      'one',
      'two',
      'three',
      'four',
      'five',
      'six',
      'seven',
      'eight',
      'nine',
    );
  }
  else {
    $labels = unserialize($labels);
  }
  $canvas = charts_graphs_get_graph($submodule);

  //  if ((strpos($type, 'pie') !== FALSE) || (strpos($type, 'donut') !== FALSE)) {
  //    $series = array(
  //      reset(array_keys($series)) => reset(array_values($series)),
  //    );
  //  }
  $canvas->title = check_plain($title);
  $canvas->width = 500;
  $canvas->height = 400;
  $canvas->type = $type;
  $canvas->y_legend = 'Y Legend';
  $canvas->colour = '#ffffff';
  $canvas->series = $series;
  $canvas->x_labels = $labels;
  $out = $canvas
    ->get_chart();
  return $out;
}