Example #1
0
 /**
  * undocumented function
  *
  * @param string $options 
  * @return void
  * @access public
  */
 function xAxis($options)
 {
     $x = null;
     if (isset($options['x_axis'])) {
         $x = new x_axis();
         $xOptions = $options['x_axis'];
         if (isset($xOptions['color'])) {
             $x->colour($xOptions['color']);
         }
         if (isset($xOptions['grid_colour'])) {
             $x->grid_colour($xOptions['grid_colour']);
         }
         if (isset($xOptions['tick_height'])) {
             $x->tick_height($xOptions['tick_height']);
         }
         if (isset($xOptions['stroke'])) {
             $x->stroke($xOptions['stroke']);
         }
         if (isset($xOptions['labels'])) {
             $x->set_labels_from_array($xOptions['labels']);
             if (isset($xOptions['label_direction'])) {
                 $x->labels->set_vertical();
             }
         }
     }
     return $x;
 }
 public function get_jx_json($info, $type = '')
 {
     $year = array_keys($info);
     $price = array_values($info);
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#FFFFFF');
     //flash背景颜色
     //$title = new title( 'UK Petrol price (pence) per Litre' );
     //$title->set_style( "{font-size: 20px; color: #A2ACBA; text-align: center;}" );
     //$chart->set_title( $title );
     $d = new hollow_dot();
     $d->size(3)->halo_size(0)->colour('#8f8fbd');
     $area = new area();
     $area->set_width(2);
     $area->set_default_dot_style($d);
     $area->set_fill_colour('#eaf6ff');
     $area->set_fill_alpha(0.4);
     $area->set_colour('#8f8fbd');
     //$area->set_values($price);
     $area->set_values($price);
     $chart->add_element($area);
     $num = intval(count($year >= 7 ? $year : 7) / 7);
     if ($num == 0) {
         $num = intval(count($year));
     }
     $num = $num > 0 ? $num : 1;
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($num);
     $x_labels->set_size(12);
     $x_labels->set_colour('#000000');
     $x_labels->set_labels($year);
     if (count($year) > 0) {
         $x_labels->set_vertical();
     }
     //		// 插入数据
     $x = new x_axis();
     $x->set_colour('#000000');
     $x->set_grid_colour('#dadada');
     $x->set_offset(false);
     $x->set_steps($num);
     // Add the X Axis Labels to the X Axis
     //$x->set_labels($x_labels);
     $x->set_labels_from_array($year);
     $chart->set_x_axis($x);
     $y = new y_axis();
     $y->labels = null;
     $max = $this->get_the_right_y(max($price));
     $max = $max > 0 ? $max : 1;
     $y->set_range(0, ($max / 5 + 1) * 5, $max / 5 + 1);
     //		if ($max > 20 && $max <= 100) {
     //
     //			$y->set_range(0, $max, 10);
     //		}elseif($max >= 10&&$max<=20){
     //			$y->set_range(0, $max, 5);
     //		}
     //		else {
     //			$y->set_range(0, $max);
     //		}
     $y->set_colour('#000000');
     $y->set_grid_colour('#dadada');
     if ($type == 'percent') {
         $y->set_label_text("       #val#%");
     } else {
         $y->set_label_text("       #val#");
     }
     $chart->add_y_axis($y);
     $info = $chart->toPrettyString();
     return $info;
 }
    } elseif ($data_max > $data_step_multiplier) {
        $data_step = $data_step_multiplier / 5;
    } else {
        $data_step = $data_step_multiplier / 10;
    }
}
$data_max = ceil($data_max / $data_step) * $data_step;
//DRAW X AXIS
$x = new x_axis();
$x->set_offset(false);
$xl_tmp = array();
foreach ($dates as $date) {
    $xl_tmp[] = date('d.m', strtotime($date));
}
$x->steps(10);
$x->set_labels_from_array($xl_tmp);
//DRAW Y AXIS
$y = new y_axis();
$y->set_offset(false);
$y->set_range(0, $data_max, $data_step);
//SET TOOLTIP FORMAT
$t = new tooltip();
$t->set_shadow(false);
$t->set_stroke(5);
$t->set_colour("#cccccc");
$t->set_background_colour("#efefef");
$t->set_body_style("{font-size:10px; font-weight:bold; color:#000000;}");
//PREPARE FINAL CHART AND RETURN IT
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($line_1);
$tdf = 'd.m.y';
$title = new title('Processed MIMS ' . date($tdf, $time_lookback) . ' - ' . date($tdf));
$title->set_style('{color: #567300; font-size: 14px}');
$bar = new bar_filled('#2020AC', '#202073', 10);
$bar->set_values(array_values($x_values));
//BAR CHART
$xfs = 11;
//x fontsize
$yfs = 12;
//y fontsize
$hfs = 16;
//header fontsize
//create chart
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
//x-label
$x = new x_axis();
$x->set_labels_from_array($x_labels);
$chart->set_x_axis($x);
//y-label
$y_points = 5;
$y_max = max($x_values);
$y_step = ceil($y_max / $y_points);
$y_max = $y_step * ($y_points + 1);
$y = new y_axis();
$y->set_range(0, $y_max, $y_step);
$chart->set_y_axis($y);
//draw data for chart
echo $chart->toString();
require_once 'confy_close.php';
Example #5
0
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . '/assets/classes/open-flash-chart/open-flash-chart.php';
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $round_labels = array();
     foreach ($data as $rw) {
         if (!$rw->homegoalspd) {
             $rw->homegoalspd = 0;
         }
         if (!$rw->guestgoalspd) {
             $rw->guestgoalspd = 0;
         }
         $homeSum[] = (int) $rw->homegoalspd;
         $awaySum[] = (int) $rw->guestgoalspd;
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->homegoalspd && !$rw->guestgoalspd) {
             $matchDayGoalsCount[] = null;
         } else {
             $matchDayGoalsCount[] = (int) $rw->homegoalspd + $rw->guestgoalspd;
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     if (!empty($homeSum) && !empty($awaySum)) {
         if ($config['home_away_stats']) {
             $bar1 = new $config['bartype_1']();
             $bar1->set_values($homeSum);
             $bar1->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_HOME') . ": #val#");
             $bar1->set_colour($config['bar1']);
             $bar1->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
             $bar1->set_key(JText::_('COM_JOOMLEAGUE_STATS_HOME'), 12);
             $bar2 = new $config['bartype_2']();
             $bar2->set_values($awaySum);
             $bar2->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_AWAY') . ": #val#");
             $bar2->set_colour($config['bar2']);
             $bar2->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
             $bar2->set_key(JText::_('COM_JOOMLEAGUE_STATS_AWAY'), 12);
             $chart->add_element($bar1);
             $chart->add_element($bar2);
         }
     }
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_STATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($matchDayGoalsCount);
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_STATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_STATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, @max($matchDayGoalsCount) + 2, 1);
     $y->set_steps(round(@max($matchDayGoalsCount) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_STATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->chartdata = $chart;
 }
 function _setPointsChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     $data = $this->get('PointsChartData');
     //echo 'data -> <pre> '.print_r($data,true).'</pre><br>';
     // Calculate Values for Chart Object
     $userpoints = array();
     $round_labels = array();
     foreach ($data as $rw) {
         if (!$rw->points) {
             $rw->points = 0;
         }
         $userpoints[] = (int) $rw->points;
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     $chart->set_bg_colour($config['bg_colour']);
     if (!empty($userpoints)) {
         $bar = new $config['bartype_1']();
         $bar->set_values($userpoints);
         $bar->set_tooltip(JText::_('COM_JOOMLEAGUE_PRED_USER_POINTS') . ": #val#");
         $bar->set_colour($config['bar1']);
         $bar->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
         $chart->add_element($bar);
     }
     //X-axis
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     //Y-axis
     $y = new y_axis();
     $y->set_range(0, @max($userpoints) + 2, 1);
     $y->set_steps(round(@max($userpoints) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_POINTS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('pointschartdata', $chart);
 }
Example #7
0
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Pragma: public");
$bar = new bar_filled('#4386a1', '#577261');
$bar_labels = array();
$bar_values = array();
foreach ($data as $label => $value) {
    $bar_labels[] = (string) $label;
    $bar_values[] = (double) $value;
}
$bar->set_values($bar_values);
$chart = new open_flash_chart();
$chart->set_title(new title($title));
$x = new x_axis();
$x->steps(1);
$x->set_labels_from_array($bar_labels);
$chart->set_x_axis($x);
$y = new y_axis();
$y->set_tick_length(7);
$y->set_range(0, (count($data) > 0 ? max($data) : 0) + 25, ((count($data) > 0 ? max($data) : 0) + 25) / 10);
$chart->set_y_axis($y);
$chart->set_bg_colour("#f3f3f3");
$chart->add_element($bar);
if (isset($yaxis_label)) {
    $y_legend = new y_legend($yaxis_label);
    $y_legend->set_style('{font-size: 20px; color: #000000}');
    $chart->set_y_legend($y_legend);
}
if (isset($xaxis_label)) {
    $x_legend = new x_legend($xaxis_label);
    $x_legend->set_style('{font-size: 20px; color: #000000}');
Example #8
0
 function loadaverage()
 {
     sleep(1);
     $uptime = trim(shell_exec("cat /proc/uptime  |awk '{print \$1}' |cut -d '.' -f 1"));
     $load_average_1min = trim(shell_exec("cat /proc/loadavg |awk '{print \$1}'"));
     $load_average_5min = trim(shell_exec("cat /proc/loadavg |awk '{print \$2}'"));
     $load_average_15min = trim(shell_exec("cat /proc/loadavg |awk '{print \$3}'"));
     if ($load_average_1min <= 1) {
         $stats = '当前系统空闲';
     } elseif ($load_average_1min <= 4) {
         $stats = '当前系统正常';
     } else {
         $stats = '当前系统繁忙';
     }
     $days = floor($uptime / 86400);
     $hours = floor($uptime % 86400 / 3600);
     $minutes = floor($uptime % 3600 / 60);
     $title = new title("系统平均负载\n{$stats}");
     $title->set_style("{font-size: 12px; font-family: Times New Roman; font-weight: bold; color: #A2ACBA; text-align: center;}");
     settype($load_average_1min, "float");
     settype($load_average_5min, "float");
     settype($load_average_15min, "float");
     $load_average = array($load_average_1min, $load_average_5min, $load_average_15min);
     function colour($value)
     {
         if ($value <= 1) {
             $colour = "#339900";
         } elseif ($value <= 4) {
             $colour = "#FFFF00";
         } else {
             $colour = "#FF0033";
         }
         return $colour;
     }
     if (max($load_average) <= 0.5) {
         $y_axis_max = 0.5;
     } elseif (max($load_average) <= 1) {
         $y_axis_max = 1;
     } elseif (max($load_average) <= 5) {
         $y_axis_max = 5;
     } elseif (max($load_average) <= 10) {
         $y_axis_max = 10;
     } elseif (max($load_average) <= 50) {
         $y_axis_max = 50;
     } else {
         $y_axis_max = 100;
     }
     $y_axis_step = $y_axis_max / 5;
     if ($load_average_1min == 0) {
         $data[0] = new bar_value($y_axis_max / 100);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip(0);
     } else {
         $data[0] = new bar_value($load_average_1min);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip('#val#');
     }
     if ($load_average_5min == 0) {
         $data[1] = new bar_value($y_axis_max / 100);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip(0);
     } else {
         $data[1] = new bar_value($load_average_5min);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip('#val#');
     }
     if ($load_average_15min == 0) {
         $data[2] = new bar_value($y_axis_max / 100);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip(0);
     } else {
         $data[2] = new bar_value($load_average_15min);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip('#val#');
     }
     $bar = new bar_glass();
     $bar->set_values($data);
     $x = new x_axis();
     $x->set_labels_from_array(array('1分钟', '5分钟', '15分钟'));
     $y = new y_axis();
     $y->set_range(0, $y_axis_max, $y_axis_step);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $x_legend = new x_legend("系统当前已运行 {$days} 天 {$hours} 小时 {$minutes} 分钟");
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toString();
 }
Example #9
0
        if ($r > $max) {
            $max = $r;
        }
        if (array_search($row[1], $lab) === FALSE) {
            $val[] = $r;
            $lab[] = $row[1];
        } else {
            $idx = array_search($row[1], $lab);
            $val[$idx] += $r;
        }
    }
}
if (count($val) < 7) {
    $lastedate = $lab[count($lab)];
    while (count($val) < 7) {
        $val[] = 0;
        $lastdate = gmdate("M-j-Y", strtotime("-1 day", strtotime($lastdate)));
        $lab[] = $lastdate;
    }
}
$bar->set_values(array_reverse($val));
$x = new x_axis();
$x->set_colour('#428C3E');
$x->set_grid_colour('#86BF83');
$x->set_labels_from_array(array_reverse($lab));
$chart->set_x_axis($x);
$y = new y_axis();
$steps = round($max / 20);
$y->set_range(0, $max, $steps);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
Example #10
0
function render_service_reports()
{
    $content = "<h1>Service Reports</h1>";
    // Start Filter for  service type
    $allServiceTypes = ServiceType::get_service_types();
    #	$allServiceTypes = array('all' => 'all');
    #$allServiceTypes = array_merge($allServiceTypes, ServiceType::get_service_types());
    $allServiceTypes['all'] = 'all';
    $service_type = $_GET['service_type'];
    $service_filter = $_GET['service_type'];
    if ($service_type == '' || !isset($service_type) || !is_numeric($service_type)) {
        $service_type = 'all';
        $service_filter = '';
    }
    $filter = "\r\n\t\t<FORM>\r\n\t\t<DIV style=\" \">\r\n\t\t<SELECT name'=service_type_report'\r\n\t\t\tonChange=\"window.location='services.php?&action=serviceReports&service_type='+this.options[this.selectedIndex].value;\">";
    foreach ($allServiceTypes as $id => $name) {
        if ($service_type == $id) {
            $selected = "SELECTED";
        } else {
            $selected = '';
        }
        $filter .= "<OPTION value='{$id}' {$selected}>{$name}\n";
    }
    $filter .= "\r\n\t\t</SELECT>\r\n\t\t</DIV>\r\n\t\t</FORM>\r\n\t";
    // End filter
    $max_date = strtotime("2009-01-01");
    $start_date = date("Y-m") . "-01";
    // Get all months since start
    $workdate = strtotime($start_date);
    $now = strtotime("Now");
    $form = new Form(auto, 3);
    $headings = array("Period", "In production", "Out of Production");
    $data = array();
    $x_ax_data = array();
    $y_ax_data = array();
    $handlers = array();
    while ($workdate > $max_date) {
        $sql_enddate = date("Y-m-d", $workdate);
        $month_period = date("m-Y", $workdate);
        // This is for the chart
        $month_label = date("M\nY", $workdate);
        $graph_date = strtotime("-1 month", $workdate);
        $month_label = date("M\nY", $graph_date);
        $sql_startdate = date("Y-m-d", $workdate);
        array_push($x_ax_data, $month_label);
        array_push($y_ax_data, count(Service::get_inprod_services_at_date($sql_startdate, $service_filter)));
        // Add one month
        $workdate = strtotime("-1 month", $workdate);
        $sql_startdate = date("Y-m-d", $workdate);
        $out_of_prod = count(Service::get_outprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        $in_prod = count(Service::get_inprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        array_push($data, "{$sql_startdate} {$sql_enddate}");
        array_push($data, $in_prod);
        array_push($data, $out_of_prod);
        array_push($handlers, "handleEvent('services.php?action=detailedServiceReports&start_date={$sql_startdate}&end_date={$sql_enddate}&service_type={$service_type}')");
    }
    $form->setTableWidth("224px");
    $form->setData($data);
    $form->setEventHandler($handlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    $content .= "<div style=\"float: left; clear: both; margin-right:28px\">" . $form->showForm() . "</div>";
    // Chart
    //
    // This is the MODEL section:
    //
    include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
    // create an X Axis object
    //
    $y_ax_data = array_reverse($y_ax_data);
    $x_ax_data = array_reverse($x_ax_data);
    $x = new x_axis();
    $x->set_steps(3);
    $x->set_labels_from_array($x_ax_data);
    $max = max($y_ax_data);
    $y = new y_axis();
    $y->set_range(0, $max);
    // Bar
    $bar = new bar();
    $bar->set_values($y_ax_data);
    // Bar
    // ------- LINE 2 -----
    $line_2_default_dot = new dot();
    $line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
    $line_2 = new line();
    $line_2->set_default_dot_style($line_2_default_dot);
    $line_2->set_values($y_ax_data);
    $line_2->set_width(3);
    $line_2->set_colour('#3D5C56');
    $chart = new open_flash_chart();
    $title = new title("In Production Services over Time");
    $title->set_style("{font-size: 10px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
    $chart->set_bg_colour('#FFFFFF');
    $chart->set_title($title);
    $chart->add_element($bar);
    //$chart->add_element( $line1 );
    $chart->add_element($line_2);
    $chart->set_x_axis($x);
    $chart->set_y_axis($y);
    //
    // This is the VIEW section:
    // Should print this first.
    //
    $heading = "\r\n\t<script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\r\n\t<script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\r\n\t<script type='text/javascript'>\r\n\tswfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '660', '350', '9.0.0');\r\n\t</script>\r\n\r\n\t<script type='text/javascript'>\r\n\r\n\tfunction open_flash_chart_data() {\r\n\t\treturn JSON.stringify(data);\r\n\t}\r\n\r\n\tfunction findSWF(movieName) {\r\n  \t\tif (navigator.appName.indexOf('Microsoft')!= -1) {\r\n    \t\t\treturn window[movieName];\r\n  \t\t} else {\r\n    \t\t\treturn document[movieName];\r\n  \t\t}\r\n\t}\r\n    \r\n\tvar data = " . $chart->toPrettyString() . "\r\n\r\n\t</script>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n \r\n\tOFC = {};\r\n \r\n\tOFC.jquery = {\r\n    \tname: 'jQuery',\r\n    \tversion: function(src) { return \$('#'+ src)[0].get_version() },\r\n    \trasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\r\n    \timage: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\r\n    \tpopup: function(src) {\r\n        var img_win = window.open('', 'Charts: Export as Image')\r\n        with(img_win.document) {\r\n            write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\r\n\t\t// stop the 'loading...' message\r\n\t\timg_win.document.close();\r\n     \t}\r\n\t}\r\n \r\n\t// Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\r\n\t//if (!Control) {var Control = {}}\r\n\t//if (typeof(Control == \"undefined\")) {var Control = {}}\r\n\tif (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\r\n \r\n \r\n\t// By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\r\n\t// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\r\n\t// function save_image() { alert(1); Control.OFC.popup('my_chart') }\r\n\tfunction save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\r\n\t</script>\r\n\t<div id='my_chart' style='float:left; margin-left:28px;'></div>\r\n\t";
    print " {$content}\n \r\n\t\t<div style=''<b>Select Service Type:</b>{$filter} <br></div>\n\r\n\t\t{$heading} ";
}
Example #11
0
 private static function make_bandwidth_chart($values, $options = array())
 {
     if (!$values || !count($values)) {
         return false;
     }
     $title = !empty($options['title']) ? $options['title'] : 'Chart';
     //array_check_value($options, 'title', 'BI Chart');
     $step = !empty($options['step']) ? $options['step'] : 0.75;
     //array_check_value($options, 'step', 0.75);
     $max = !empty($options['max']) ? $options['max'] : 0;
     //array_check_value($options, 'max', 0);
     $value_mod = !empty($options['value_modifier']) ? $options['value_modifier'] : 1;
     //array_check_value($options, 'value_modifier', 1);
     $input_title = !empty($options['input_title']) ? $options['input_title'] : 'Downloads for :key: #val#';
     //array_check_value($options, 'input_title', 'Downloads for :key: #val#');
     $output_title = !empty($options['output_title']) ? $options['output_title'] : 'Uploads for :key: #val#';
     //array_check_value($options, 'output_title', 'Uploads for :key: #val#');
     $total_title = !empty($options['total_title']) ? $options['total_title'] : 'Total for :key: #val#';
     //array_check_value($options, 'total_title', 'Total for :key: #val#');
     $on_click = !empty($options['on_click']) ? $options['on_click'] : false;
     //array_check_value($options, 'on_click', false);
     $x_labels = !empty($options['x_labels']) ? $options['x_labels'] : array_keys($values);
     //array_check_value($options, 'x_labels', array_keys($values));
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_title.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/open-flash-chart.php';
     //include(APP_FOLDER . '/libraries/php-ofc-library/ofc_bar_glass_value.php');
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_dot.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_base.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_x_axis.php';
     $title = new title($title);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $input = array();
     $ouput = array();
     $total = array();
     $clicks = array();
     foreach ($values as $key => $value) {
         $this_value = (double) number_format($value['input'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $input_title));
         $input[] = $tmp;
         $this_value = (double) number_format($value['output'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $output_title));
         $output[] = $tmp;
         $this_value = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
         $tmp = new dot_value($this_value, '#000066');
         $tmp->set_tooltip(preg_replace('/:key/', $key, $total_title));
         $total[] = $tmp;
         if ($on_click) {
             $tmp = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
             $clicks[] = $tmp;
         }
         $max = ceil(max(($value['input'] + $value['output']) / $value_mod, $max));
     }
     $x_axis = new x_axis();
     $x_axis->set_labels_from_array($x_labels);
     $x_axis->set_3d(5);
     $x_axis->colour = '#909090';
     if ($max > 0) {
         //Don't know why we sometimes get a division by zero error
         @($max = $max + ($step - $max % $step));
     }
     if ($max / $step > 5) {
         $step = floor($max / 5);
     } else {
         if ($max / $step <= 1) {
             $step = floor($max / 2);
         }
     }
     $y_axis = new y_axis();
     $y_axis->set_range(0, $max, $step);
     $input_bar = new bar_glass();
     $input_bar->set_values($input);
     $input_bar->colour = '#D54C78';
     $output_bar = new bar_glass();
     $output_bar->set_values($output);
     $output_bar->colour = '#78D54C';
     $total_graph = new line_hollow();
     $total_graph->set_colour('#9999FF');
     $total_graph->set_values($total);
     if ($on_click) {
         $click_graph = new line();
         $click_graph->set_values($clicks);
         $click_graph->set_on_click($on_click);
         $chart->add_element($click_graph);
     }
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     $chart->add_element($input_bar);
     $chart->add_element($output_bar);
     $chart->add_element($total_graph);
     //$decoded = json_decode($chart->toString());
     return $chart->toString();
 }
Example #12
0
function stacked_bar_chart($host_instance_list)
{
    $title = new title('所有instance实际内存使用');
    $title->set_style("{color: #567300; font-size: 16px; font-weight:bold;}");
    $bar_stack = new bar_stack();
    $bar_stack->set_colours(array('#C4D318', '#7D7B6A'));
    $max = 64;
    foreach ($host_instance_list as $i => $instance) {
        $jvmmem = isset($instance['jvmmem']) ? explode('/', $instance['jvmmem']) : array();
        if ($jvmmem) {
            foreach ($jvmmem as &$j) {
                $j = intval($j);
            }
            $max = $max < $jvmmem[1] ? $jvmmem[1] : $max;
            $jvmmem[1] = $jvmmem[1] - $jvmmem[0];
        }
        $bar_stack->append_stack($jvmmem);
        $lables[] = $instance['port_num'];
        $services[$i] = $instance['service_name'];
    }
    $bar_stack->set_keys(array(new bar_stack_key('#C4D318', 'used', 13), new bar_stack_key('#7D7B6A', 'total', 13)));
    $bar_stack->set_on_click('(function(x){var services=' . json_encode($services) . ';alert(services[x]);})');
    //js
    $bar_stack->set_tooltip('#val#M,共#total#M');
    $y = new y_axis();
    $y->set_range(0, $max + 32, 256);
    $x = new x_axis();
    $x->set_labels_from_array($lables);
    $tooltip = new tooltip();
    $tooltip->set_hover();
    $chart = new open_flash_chart();
    $chart->set_title($title);
    $chart->add_element($bar_stack);
    $chart->set_x_axis($x);
    $chart->add_y_axis($y);
    $chart->set_tooltip($tooltip);
    return $chart->toPrettyString();
}
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $matchDayGoalsCount[] = 0;
     $round_labels = array();
     $matchDayGoalsCountMax = 0;
     foreach ($data as $rw) {
         if (!$rw->goalsfor) {
             $rw->goalsfor = 0;
         }
         if (!$rw->goalsagainst) {
             $rw->goalsagainst = 0;
         }
         $forSum[] = intval($rw->goalsfor);
         $againstSum[] = intval($rw->goalsagainst);
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->goalsfor && !$rw->goalsagainst) {
             $matchDayGoalsCount[] = 0;
         } else {
             $matchDayGoalsCount[] = intval($rw->goalsfor + $rw->goalsagainst);
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     $barfor = new $config['bartype_1']();
     $barfor->set_values($forSum);
     $barfor->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR') . ": #val#");
     $barfor->set_colour($config['bar1']);
     $barfor->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
     $barfor->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR'), 12);
     $baragainst = new $config['bartype_2']();
     $baragainst->set_values($againstSum);
     $baragainst->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST') . ": #val#");
     $baragainst->set_colour($config['bar2']);
     $baragainst->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
     $baragainst->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST'), 12);
     $chart->add_element($barfor);
     $chart->add_element($baragainst);
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values(array_slice($matchDayGoalsCount, 1));
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, max($matchDayGoalsCount) + 2, $config['y_axis_steps']);
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('chartdata', $chart);
 }
Example #14
0
 case "4":
     // penghasilan
     srand((double) microtime() * 1000000);
     $data = array();
     // add random height bars:
     for ($i = 0; $i < 10; $i++) {
         $data[] = rand(2, 9);
     }
     require_once '../php-ofc-library/open-flash-chart.php';
     $title = new title("Penghasilan Penduduk ");
     $bar = new bar();
     $bar->set_values($data);
     $bar->colour = '#D54C78';
     $x_axis = new x_axis();
     $x_axis->set_colour('#909090');
     $x_axis->set_labels_from_array(array("Gedangan", "Sawo", "3", "4", "5", "6", "7", "8", "9", "10"));
     $y_axis = new y_axis();
     $y_axis->set_label_text(array("Make garden look sexy", "Paint house", "Move into house"));
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_x_axis($x_axis);
     $chart->add_y_axis($y_axis);
     echo $chart->toPrettyString();
     break;
 case "5":
     $additional = array();
     $additional[] = array("key" => 'all', "value" => "All");
     echo "<li><label for='kecamatan'>Kecamatan</label>";
     echo select("kecamatan", "id", "nama_kecamatan", "kecamatan", 'class="ui-widget-content ui-corner-all"', "", -1, $additional);
     echo "</li><li><label for='kelurahan' id='lbl_desa'>Desa/Kelurahan</label></li>";