You are here

function ChartsGraphsAmcharts::_preprocess_values_not_pie in Charts and Graphs 6.2

Same name and namespace in other branches
  1. 7 apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc \ChartsGraphsAmcharts::_preprocess_values_not_pie()
1 call to ChartsGraphsAmcharts::_preprocess_values_not_pie()
ChartsGraphsAmcharts::_preprocess_values in apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc

File

apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc, line 102

Class

ChartsGraphsAmcharts
Implementation of abstract class ChartsGraphsFlashCanvas for amCharts library.

Code

function _preprocess_values_not_pie() {
  $series = array();
  if (is_array($this->x_labels)) {
    $i = 1;

    /**
     * Making amCharts side bar graphs have the same orientation of side bar
     * graphs made with Bluff and Google Charts.
     */
    $x_labels = $this->type == 'side_bar' ? array_reverse($this->x_labels) : $this->x_labels;
    foreach ($x_labels as $label) {
      $series[] = array(
        '#id' => 'value',
        '#value' => $this
          ->encode_for_xml($label),
        '#attributes' => array(
          'xid' => $i,
        ),
      );
      $i++;
    }
  }
  $graphs = array();
  if (is_array($this->series)) {

    /**
     * Making amCharts side bar graphs have the same orientation of side bar
     * graphs made with Bluff and Google Charts.
     */
    $ordered_series = $this->type == 'side_bar' ? array_reverse($this->series, TRUE) : $this->series;
    $gid = 0;
    foreach ($ordered_series as $name => $graph) {
      if (!is_array($graph)) {
        continue;
      }
      $j = 1;
      $values = array();

      /**
       * Making amCharts side bar graphs have the same orientation of side bar
       * graphs made with Bluff and Google Charts.
       */
      $ordered_graph = $this->type == 'side_bar' ? array_reverse($graph, TRUE) : $graph;
      foreach ($ordered_graph as $val) {
        $values[] = array(
          '#id' => 'value',
          '#value' => $this
            ->encode_for_xml($val),
          '#attributes' => array(
            'xid' => $j,
          ),
        );
        $j++;
      }
      $new_graph = array(
        '#id' => 'graph',
        '#attributes' => array(
          'title' => $this
            ->encode_for_xml($name),
          'bullet' => 'round',
          'gid' => $gid,
        ),
        '#children' => $values,
      );
      if (strpos($this->type, 'area') !== FALSE) {
        $new_graph['#attributes']['fill_alpha'] = 50;
      }
      $graphs[] = $new_graph;
      $gid++;
    }
  }
  $series = $this
    ->merge_xml_values($series, $this->chart_series);
  $graphs = $this
    ->merge_xml_values($graphs, $this->chart_graphs);
  $series = array(
    '#id' => 'series',
    '#children' => $series,
  );
  $graphs = array(
    '#id' => 'graphs',
    '#children' => $graphs,
  );
  $chart = array(
    '#id' => 'chart',
    '#children' => array(
      $series,
      $graphs,
    ),
  );
  $this->data_to_use = array(
    $chart,
  );
}