Exemplo n.º 1
0
 public function construct()
 {
     if (!self::$included) {
         $dir = $this->get_module_dir();
         ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $dir . '/2-lug');
         require_once 'OFC/OFC_Chart.php';
         self::$included = true;
     }
     $this->ofc = new OFC_Chart();
 }
Exemplo n.º 2
0
 public function body()
 {
     $f = $this->init_module(Libs_OpenFlashChart::module_name());
     $title = new OFC_Elements_Title(date("D M d Y"));
     $f->set_title($title);
     $bar = new OFC_Charts_Bar();
     $bar->set_values(array(9, 8, 7, 6, 5, 4, 3, 2, 1));
     $f->add_element($bar);
     $this->display_module($f);
     $f2 = $this->init_module(Libs_OpenFlashChart::module_name());
     $title = new OFC_Elements_Title(date("D M d Y"));
     $f2->set_title($title);
     $bar = new OFC_Charts_Bar_Glass();
     $data = array();
     for ($i = 1; $i < 10; $i++) {
         $data[] = rand() % 10;
     }
     $bar->set_values($data);
     $f2->add_element($bar);
     $bar = new OFC_Charts_Line();
     $data = array();
     for ($i = 1; $i < 10; $i++) {
         $data[] = rand() % 10;
     }
     $bar->set_values($data);
     $bar->set_colour('#FF0000');
     $f2->add_element($bar);
     $this->display_module($f2);
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/OpenFlashChart/OpenFlashChartInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/OpenFlashChart/OpenFlashChart_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/OpenFlashChart/OpenFlashChartCommon_0.php');
 }
Exemplo n.º 3
0
 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);
 }