You are here

function ChartsOpenFlash::_preprocess_values in Charts and Graphs 7

Same name and namespace in other branches
  1. 6 apis/charts_openflash/charts_openflash.class.inc \ChartsOpenFlash::_preprocess_values()

Pie-chart has different format for $values array than bar chart etc. This method deals with permutations across chart types. Sigh.

<p> We also remove items with no label, while we are at it, since those can cause problems to Flash renderer.

1 call to ChartsOpenFlash::_preprocess_values()
ChartsOpenFlash::get_data_from_cache in apis/charts_openflash/charts_openflash.class.inc

File

apis/charts_openflash/charts_openflash.class.inc, line 105

Class

ChartsOpenFlash

Code

function _preprocess_values($values) {
  $labels = $this->x_axis->labels->labels;
  $i = 0;
  switch ($this->type) {
    case 'pie':
      $new_vals = array();
      foreach ($values as $val) {
        if (!empty($labels[$i]) && $labels[$i] != 'null') {

          // An accidental empty label causes SWF to go nuts
          $obj = new stdClass();
          $obj->value = $val;
          $obj->label = $labels[$i];
          $arr = array(
            'value' => $val,
            'label' => $labels[$i],
          );
          $new_vals[] = $obj;
        }
        $i++;
      }
      return $new_vals;
    default:

      // Default action is just filtering values with nulled labels (leftovers from out joins)
      $new_vals = array();
      $new_labels = array();
      foreach ($values as $val) {
        if (!empty($labels[$i]) && $labels[$i] != 'null') {

          // An accidental empty label causes SWF to go nuts
          $new_vals[] = $val;
          $new_labels[] = $labels[$i];
        }
        $i++;
      }
      $this->x_axis->labels->labels = $new_labels;
      return $new_vals;
  }
}