public function draw_category_chart($ref_rec, $gb_captions) { $f = $this->init_module(Libs_OpenFlashChart::module_name()); $title = new OFC_Elements_Title($ref_rec); $f->set_title($title); $labels = array(); foreach ($gb_captions as $cap) { $labels[] = $cap['name']; } $x_ax = new OFC_Elements_Axis_X(); $x_ax->set_labels_from_array($labels); $f->set_x_axis($x_ax); $max = 5; $color = 0; foreach ($this->ref_records as $q => $r) { $results = call_user_func($this->display_cell_callback, $r); $title2 = strip_tags(call_user_func($this->ref_record_display_callback, $r, true)); $bar = new OFC_Charts_Line(); $bar->set_colour(self::$colours[$color % count(self::$colours)]); $color++; $bar->set_key($title2, 10); $arr = array(); foreach ($results as $v) { if ($ref_rec) { if (is_array($v[$ref_rec])) { $v[$ref_rec] = array_pop($v[$ref_rec]); } $val = (double) strip_tags($v[$ref_rec]); } else { if (is_array($v)) { $v = array_pop($v); } $val = (double) strip_tags($v); } $arr[] = $val; if ($max < $val) { $max = $val; } } $bar->set_values($arr); $f->add_element($bar); } $y_ax = new OFC_Elements_Axis_Y(); $y_ax->set_range(0, $max); $y_ax->set_steps($max / 10); $f->set_y_axis($y_ax); $f->set_width(950); $f->set_height(400); $this->display_module($f); }
public function toObject() { $this->consolidateParameters(); $xAxisLabels = new OFC_Elements_Axis_X_Label_Set(); $xAxisLabels->set_labels($this->labels); $xAxisLabels->set_size(10); $xAxisLabels->set_colour('#444444'); $xAxisLabels->set_steps($this->stepsX); $xAxis = new OFC_Elements_Axis_X(); $xAxis->set_steps($this->stepsX); $xAxis->set_labels($xAxisLabels); $xAxis->set_colour('#CCCCCC'); $xAxis->set_grid_colour('#AAAAAA'); $this->chart->set_x_axis($xAxis); $yAxis = new OFC_Elements_Axis_Y(); $yAxis->set_range($this->min1, $this->max1); $yAxis->set_colour('#AAAAAA'); $yAxis->set_grid_colour('#AAAAAA'); $yAxis->set_steps($this->stepsY1); $this->chart->set_y_axis($yAxis); $yLegend = new OFC_Elements_Legend_Y($this->data1->getName()); //$this->chart->set_y_legend($yLegend); // does not work now // data 1 $this->chart->add_element($this->createGraph($this->data1)); if ($this->hasTwoDataLines()) { $yAxisRight = new OFC_Elements_Axis_Y_Right(); $yAxisRight->set_range($this->min2, $this->max2); $yAxisRight->set_colour('#AAAAAA'); $yAxisRight->set_steps($this->stepsY2); // $this->chart->set_y_axis_right($yAxisRight); $this->chart->add_element($this->createGraph($this->data2)); } return $this->chart; }