function ChartsOpenFlash::_preprocess_values in Charts and Graphs 6
Same name and namespace in other branches
- 7 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.
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 140 - Implementation of abstract class ChartCanvas for Open Charts Flash 2 library.
Class
- ChartsOpenFlash
- Implementation of abstract class ChartCanvas for Open Charts Flash 2 library.
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) {
// An accidental empty label causes SWF to go nuts.
if (!empty($labels[$i]) && $labels[$i] != 'null') {
$obj = new stdClass();
$obj->value = $val;
$obj->label = $labels[$i];
$new_vals[] = $obj;
}
$i++;
}
return $new_vals;
/**
* Default action is just filtering values with nulled labels (leftovers
* from out joins).
*/
default:
$new_vals = array();
$new_labels = array();
foreach ($values as $val) {
// An accidental empty label causes SWF to go nuts.
if (!empty($labels[$i]) && $labels[$i] != 'null') {
$new_vals[] = $val;
$new_labels[] = $labels[$i];
}
$i++;
}
$this->x_axis->labels->labels = $new_labels;
return $new_vals;
}
}