function build($options = array()) { if (empty($options)) { return false; } require_once WWW_ROOT . 'php-ofc-library/open-flash-chart.php'; $chart = new open_flash_chart(); if (isset($options['title']['txt'])) { $title = new title($options['title']['txt']); if (isset($options['title']['style'])) { $title->set_style("{" . $options['title']['style'] . "}"); } $chart->set_title($title); } if (isset($options['chart']['bg'])) { $chart->set_bg_colour($options['chart']['bg']); } if (isset($xOptions['color'])) { $x->colour($xOptions['color']); } if (isset($xOptions['grid_colour'])) { $x->grid_colour($xOptions['grid_colour']); } $col = isset($options['color']) ? $options['color'] : null; $outlineCol = isset($options['outline_col']) ? $options['outline_col'] : null; if (isset($options['charts'])) { foreach ($options['charts'] as $chartOpts) { $type = isset($chartOpts['type']) ? $chartOpts['type'] : 'bar_filled'; $diagram = new $type($chartOpts['col'], $chartOpts['outline']); if ($type == 'bar_3d') { $diagram->colour = $col; } $diagram->set_values($chartOpts['values']); if (isset($chartOpts['key'])) { $diagram->key($chartOpts['key'], 12); } $xAxis = $this->xAxis($options); if ($xAxis !== null) { $chart->set_x_axis($xAxis); } $yAxis = $this->yAxis($options); if ($xAxis !== null) { $chart->set_y_axis($yAxis); } if (isset($chartOpts['tooltip'])) { $diagram->set_tooltip($chartOpts['tooltip']); } $chart->add_element($diagram); } } return $chart->toPrettyString(); }
function clientstatAction() { if (!$this->clientdashboardfilter()) { return; } $this->view->activeTab = 'clientstat'; // process data for chart include 'open-flash-chart.php'; $request = $this->getRequest(); $this->view->campaign_id = $request->getParam('id'); $campaignModel = new Campaign(); $campaign = $campaignModel->fetchRow('id = ' . $this->view->campaign_id); $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign->id)); //if session not exist, get data from webservice $reportMap = array(); $array_data = $this->getReportCountbyCampaign($campaign, 0, $reportMap); $sum = 0; foreach ($array_data as $date) { $sum += $date; } $i = 0; $maxY = 0; foreach ($array_data as $date) { $array_data[$i] = round($date * 100 / $sum, 1); if ($array_data[$i] > $maxY) { $maxY = $array_data[$i]; } $i++; } // create chart $array_create_date = array('0', '1', '2', '3', '4', '5', '6', '7'); $title = new title("Kraft Spraks Comments"); $title->set_style('{font-size: 14px; color: #FFFFFF; }'); $max_y = floor($maxY / 10) * 10 + 10; $y = new y_axis(); $y->set_range(0, $max_y, 10); $x = new x_axis(); $x_labels = new x_axis_labels(); $x_labels->set_labels($array_create_date); $x_labels->set_size(11); $x->set_labels($x_labels); $x->set_range(0, 7, 1); //There is a bug on the tooltip of bar: can not show #x_label#. So use bar_stack instead of bar here. $bar = new bar_filled(); $array_bar_data[0] = new bar_value($array_data[0]); $array_bar_data[0]->set_colour('#606060'); $array_bar_data[1] = new bar_value($array_data[1]); $array_bar_data[1]->set_colour('#BE3304'); $array_bar_data[2] = new bar_value($array_data[2]); $array_bar_data[2]->set_colour('#F2B538'); $array_bar_data[3] = new bar_value($array_data[3]); $array_bar_data[3]->set_colour('#EE7904'); $array_bar_data[4] = new bar_value($array_data[4]); $array_bar_data[4]->set_colour('#D4FD32'); $array_bar_data[5] = new bar_value($array_data[5]); $array_bar_data[5]->set_colour('#B4EB35'); $array_bar_data[6] = new bar_value($array_data[6]); $array_bar_data[6]->set_colour('#B1D764'); $array_bar_data[7] = new bar_value($array_data[7]); $array_bar_data[7]->set_colour('#A1C463'); $bar->set_values($array_bar_data); // $bar->set_tooltip('#x_label#: #val#'); // $bar = new bar_stack(); // $bar->set_colours(array( '#E2D66A', '#A0C361' )); // foreach ($array_data as $date): // $bar->append_stack(array((int)$date)); // endforeach; $bar->set_tooltip('#val#%'); $x_legend = new x_legend('Positive'); $x_legend->set_style('{font-size: 30px; color: #FFFFFF; }'); $y_legend = new y_legend($this->view->translate('(%)')); $y_legend->set_style('{font-size: 30px; color: #FFFFFF;}'); $tags = new ofc_tags(); $tags->font("Verdana", 14)->align_x_right(); $tag_y_value = -($max_y * 0.3); $t = new ofc_tag(6.6, $tag_y_value); $t->text($this->view->translate('Client_Report Positive'))->colour("#177A16"); $tags->append_tag($t); $t2 = new ofc_tag(0.5, $tag_y_value); $t2->text($this->view->translate('Client_Report Negative'))->colour("#D88569"); $tags->append_tag($t2); $t3 = new ofc_tag(-1, $max_y); $t3->text($this->view->translate('(%)'))->colour("#000000"); $tags->append_tag($t3); $t4 = new ofc_tag(-0.7, $tag_y_value); $t4->text($this->view->translate('Client_Report No opinion'))->colour("#5D5D5D"); $tags->append_tag($t4); $this->view->chart3 = new open_flash_chart(); $this->view->chart3->set_title($title); $this->view->chart3->add_element($bar); $this->view->chart3->set_bg_colour('#FFFFFF'); $this->view->chart3->set_x_axis($x); $this->view->chart3->set_y_axis($y); $this->view->chart3->set_x_legend($x_legend); $this->view->chart3->set_y_legend($y_legend); $this->view->chart3->add_element($tags); }
<?php include '../../includes/admin_config.php'; include 'ofc-library/open-flash-chart.php'; $days = 10; $last_week = time() - 86400 * $days + 86400; $the_last_week = date('M d', $last_week); $title = new title("ClipBucket Daily Activity " . $the_last_week . " - " . date("M d")); $title->set_style("{font-size:14px;font-family:Century Gothic;font-weight:bold}"); $vid_stats = $data['video_stats']; $vid_stats = json_decode($vid_stats); $year = array(); //Getting This Weeks Data for ($i = 0; $i < $days; $i++) { if ($i < $days - 1) { $date_pattern = date("Y-m-d", $last_week + $i * 86400); //echo "date_added LIKE '%$date_pattern%'"; $data = $db->select(tbl("stats"), "*", " date_added LIKE '%{$date_pattern}%' ", 1); $data = $data[0]; $datas[] = $data; } $year[] = date("M d", $last_week + $i * 86400); } for ($i = 0; $i < $days; $i++) { $day[$i]['video'] = json_decode($datas[$i]['video_stats']); $day[$i]['users'] = json_decode($datas[$i]['user_stats']); $day[$i]['groups'] = json_decode($datas[$i]['group_stats']); } $max = 1; for ($i = 0; $i < $days; $i++) { if ($i == $days - 1) {
$theValue = $theValue != "" ? intval($theValue) : "NULL"; break; case "double": $theValue = $theValue != "" ? doubleval($theValue) : "NULL"; break; case "date": $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $title = new title(); $title->set_style("font-size:12px; font-weight:bold;"); $pie = new pie(); $pie->set_alpha(0.6); $pie->set_start_angle(32); $pie->add_animation(new pie_fade()); $pie->set_tooltip('#val# ' . $multilingual_project_hour); $pie->set_colours(array('#99C754', '#54C7C5', '#999999', '#996699', '#009900', '#77C600', '#ff7400', '#FF0000', '#4096ee', '#c79810')); $projectid = $_GET['recordID']; mysql_select_db($database_tankdb, $tankdb); $query_Recordset_sumtotal = sprintf("SELECT \n\t\t\t\t\t\t\tsum(csa_tb_manhour) as sum_hour \n\t\t\t\t\t\t\tFROM tk_task_byday \t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tWHERE csa_tb_backup2 = %s", GetSQLValueString($projectid, "text")); $Recordset_sumtotal = mysql_query($query_Recordset_sumtotal, $tankdb) or die(mysql_error()); $row_Recordset_sumtotal = mysql_fetch_assoc($Recordset_sumtotal); $t = $row_Recordset_sumtotal['sum_hour']; $sql = sprintf("SELECT * , sum(csa_tb_manhour) as summ1 FROM tk_task_byday \t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tinner join tk_task_tpye on tk_task_byday.csa_tb_backup4=tk_task_tpye.id\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tWHERE csa_tb_backup2 = %s GROUP BY csa_tb_backup4 ORDER BY summ1 DESC", GetSQLValueString($projectid, "text")); $query = mysql_query($sql, $tankdb) or die(mysql_error());
/** * Sets the title above the chart. You can also style it with * css as the second parameter. * * @example $flashChart->setTitle('Awesomeness'); * @example $flashChart->setTitle('Coolness, by date','{font-size:26px;}'); * @param string $title_text * @param string $style css */ public function setTitle($title_text, $style = '') { $title = new title($title_text); if (empty($style)) { $style = $this->title_style; } $title->set_style($style); $this->Chart->set_title($title); }
$year[] = '2002'; $price[] = 69.90000000000001; $year[] = '2003'; $price[] = 77.90000000000001; $year[] = '2004'; $price[] = 77.90000000000001; $year[] = '2005'; $price[] = 79.90000000000001; $year[] = '2006'; $price[] = 88.90000000000001; $year[] = '2007'; $price[] = 87.90000000000001; $year[] = '2008'; $price[] = 103.9; $chart = new open_flash_chart(); $title = new title('UK Petrol price (pence) per Litre'); $title->set_style("{font-size: 20px; color: #A2ACBA; text-align: center;}"); $chart->set_title($title); $area = new area(); $area->set_colour('#8f8fbd'); $area->set_values($price); $area->set_key('Price', 12); $chart->add_element($area); $x_labels = new x_axis_labels(); $x_labels->set_steps(2); $x_labels->set_vertical(); $x_labels->set_colour('#A2ACBA'); $x_labels->set_labels($year); // ²åÈëÊý¾Ý $x = new x_axis(); $x->set_colour('#dadada');
$data = array(); $dataraw = array(); while ($row = tep_db_fetch_array($r)) { $dataraw[$row['status']] = $row['status_total']; } $statuslist = array('1', '2', '7', '3', '4', '5', '6'); $statuscolor = array('1' => '#bababa', '2' => '#ababab', '7' => '#838383', '3' => '#900000', '4' => '#ffd200', '5' => '#0066CC', '6' => '#066303'); $statustext = array(); foreach ($statuslist as $status) { $text = ($status == '1' ? 'New ' : 'Moved to ') . improvement::getImprovementStatus($status); $statustext[$status] = $text; $bar = new bar_value(intval($dataraw[$status])); $bar->set_colour($statuscolor[$status]); $data[$status] = $bar; } $title = new title('MIMS ' . $time_lookback_date . '-' . $time_lookuntil_date . ' (' . array_sum($dataraw) . ')'); $title->set_style("{font-size:13px;font-weight:bold;margin:5px 0 20px 0;}"); $chart = new open_flash_chart(); $chart->set_title($title); /* // PIE CHART $pie = new pie(); $pie->set_alpha(0.6); $pie->set_start_angle(-90); $pie->add_animation( new pie_fade() ); $pie->set_tooltip('#val# of #total#<br>#percent# of 100%'); $pie->set_colours(array('#bababa', '#ababab', '#838383', '#900000', '#ffd200', '#0066CC', '#066303')); $pie->set_values($data); $chart->add_element( $pie ); */ //BAR CHART
/** * public static function to generate two pie charts for the mailing reports * It was extracted because there are two graph in mailing for each mailing and general mailing which is the total * * @param array $results data needed for graph values */ public static function mailingPieChart($results) { $data = array(); //First Pie, Pie Chart for HTML/TEXT format $valuesFormat = array(); $pieHtmlValues = new pie_value((int) $results['html_sent'], _JNEWS_GRAPH_LBL_HTML); $pieTextValues = new pie_value((int) $results['text_sent'], _JNEWS_GRAPH_LBL_TEXT); $valuesFormat[] = $pieHtmlValues; $valuesFormat[] = $pieTextValues; if (empty($results['html_sent']) && empty($results['text_sent'])) { $data['pie1'] = 'empty'; } else { $css = '{font-size:15px;font-weight:bold;color:#0B55C4;}'; $title = new title(_JNEWS_GRAPH_TITLE_FORMAT); //Name of the newsletter $title->set_style($css); $pieMailing = new pie(); $pieMailing->set_alpha(0.6); $pieMailing->set_start_angle(35); $pieMailing->add_animation(new pie_fade()); $pieMailing->set_tooltip('#val#<br>#percent# of 100%'); $pieMailing->set_colours(array('#156cbd', '#368d03', '#f7941d', '#ed145a', '#92278f', '#156cbd', '#182972', '#3e5d2b', '#db4b19', '#9d0039', '#440e62')); $pieMailing->set_values($valuesFormat); $chartPie = new open_flash_chart(); $chartPie->set_title($title); $chartPie->add_element($pieMailing); $chartPie->set_bg_colour('#FFFFFF'); $data['pie1'] = $chartPie->toPrettyString(); } //Second chart, Pie chart for the status of mailing process $valuesProcess = array(); //$pieFailedlValues = new pie_value((int)$results['failed'], _JNEWS_MAILING_FAILED); //$pieBounceValues = new pie_value((int)$results['bounces'], _JNEWS_MAILING_BOUNCES); $piePendingValues = new pie_value((int) $results['pending'], _JNEWS_MAILING_PENDING); $pieSentValues = new pie_value((int) $results['sent'], _JNEWS_MAILING_SENT); //$valuesProcess[] = $pieFailedlValues; //$valuesProcess[] = $pieBounceValues; $valuesProcess[] = $piePendingValues; $valuesProcess[] = $pieSentValues; //if(!empty($results['failed']) && !empty($results['pending']) && !empty($results['bounces'])){ if (!empty($results['sent']) || !empty($results['pending'])) { $css = '{font-size:15px;font-weight:bold;color:#0B55C4;}'; $title = new title(_JNEWS_GRAPH_PIE_TITLE_MAIL); //Name of the newsletter $title->set_style($css); $pieMailing = new pie(); $pieMailing->set_alpha(0.6); $pieMailing->set_start_angle(35); $pieMailing->add_animation(new pie_fade()); $pieMailing->set_tooltip('#val#<br>#percent# of 100%'); $pieMailing->set_colours(array('#156cbd', '#368d03', '#f7941d', '#ed145a', '#92278f', '#156cbd', '#182972', '#3e5d2b', '#db4b19', '#9d0039', '#440e62')); $pieMailing->set_values($valuesProcess); $chartPie = new open_flash_chart(); $chartPie->set_title($title); $chartPie->add_element($pieMailing); $chartPie->set_bg_colour('#FFFFFF'); $data['pie2'] = $chartPie->toPrettyString(); } else { $data['pie2'] = 'empty'; } return $data; }
private function getChart($aGraphs) { $this->prepareData(); $oLabels = new x_axis_labels(); $oLabels->set_labels($this->aData[0]); $oLabels->rotate(-45); $oX = new x_axis(); $oX->set_labels($oLabels); $oX->set_colours('#000000', '#ffffff'); $oChart = new open_flash_chart(); $oChart->set_bg_colour('#FFFFFF'); $oTitle = new title($this->getTitle()); $oTitle->set_style('font-size: 12px; font-weight: bold;'); $oChart->set_title($oTitle); $oTooltip = new tooltip('#val#'); $oTooltip->set_body_style('font-size: 10px'); $oTooltip->set_stroke(1); $oTooltip->set_shadow(true); $oTooltip->set_background_colour('#ffffcc'); $oTooltip->set_colour('#cccc99'); $oChart->set_tooltip($oTooltip); $aY = array(); foreach ($aGraphs as $k => $v) { $y = empty($v['y-right']) ? 0 : 1; $scale = empty($v['scale']) ? 1 : $v['scale']; if (!isset($aY[$y])) { $aY[$y] = new y_axis(); $aY[$y]->set_colours($v['colour'], '#f6f6f6'); } if (empty($v['y-remap'])) { $this->setAxisRange($aY[$y], $k, $scale); } else { $this->remapSeries($aY[$y], $k, $scale); } $oSeries = $this->getSeries($k, $v['type'], $v['colour']); if (!empty($this->drillDown)) { $oSeries->set_on_click($this->drillDown); } $oSeries->set_on_show($v['effect']); if ($y) { $oSeries->attach_to_right_y_axis(); } $aGraphs[$k] = $oSeries; } $oChart->set_x_axis($oX); foreach ($aY as $y => $e) { $method = $y ? 'set_y_axis_right' : 'set_y_axis'; $oChart->{$method}($e); } foreach ($aGraphs as $e) { $oChart->add_element($e); } return $oChart; }
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} "; }
function netio() { function bit_to_kb($n) { return round($n / 1000, 2); } function bit_to_mb($n) { return round($n / 1000000, 2); } function get_data() { $recv_l = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8; sleep(1); $recv_n = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8; return $recv_n - $recv_l; } if (array_key_exists('netio', $_SESSION) && array_key_exists('recv_l', $_SESSION)) { if (count($_SESSION['netio']) == 10) { array_shift($_SESSION['netio']); $_SESSION['netio'][] = get_data(); } else { $_SESSION['netio'][] = get_data(); $_SESSION['recv_l'] = end($_SESSION['netio']); } } else { $_SESSION['netio'] = array(0, 0, 0, 0, 0, 0, 0, 0, 0); $_SESSION['netio'][] = get_data(); $_SESSION['recv_l'] = end($_SESSION['netio']); } $data = $_SESSION['netio']; /* $data = array(); for($i=0;$i<40;$i++){ $data[] = rand(1000000,10000000); } */ foreach (range(1, 10) as $i) { settype($i, 'string'); $second[] = $i; } if (max($data) <= 1000) { $data = array_map("bit_to_kb", $data); $y_axis_max = 1; $y_axis_key_text = " KB/s"; } elseif (max($data) <= 10000) { $data = array_map("bit_to_kb", $data); $y_axis_max = 10; $y_axis_key_text = " KB/s"; } elseif (max($data) <= 100000) { $data = array_map("bit_to_kb", $data); $y_axis_max = 100; $y_axis_key_text = " KB/s"; } elseif (max($data) <= 1000000) { $data = array_map("bit_to_kb", $data); $y_axis_max = 1000; $y_axis_key_text = " KB/s"; } elseif (max($data) <= 10000000) { $data = array_map("bit_to_mb", $data); $y_axis_max = 10; $y_axis_key_text = " MB/s"; } else { $data = array_map("bit_to_mb", $data); $y_axis_max = 100; $y_axis_key_text = " MB/s"; } $y_axis_step = $y_axis_max / 5; $chart = new open_flash_chart(); $title = new title("实时流量显示"); $title->set_style("{font-size: 12px; color: #A2ACBA; text-align: center;}"); $chart->set_title($title); #点是指曲线图上的顶点 # $d = new dot(); # $d->colour('#9C0E57')->size(3); $area = new area(); #width是指曲线的宽度 # $area->set_width(3); # $area->set_default_dot_style($d); $area->set_colour('#5B56B6'); #value即曲线顶的值 $area->set_values($data); #左上角的文字 $area->set_key($y_axis_key_text, 10); $area->set_fill_colour('#CCCAAA'); #设透明度 $area->set_fill_alpha(0.3); #area设置结束,使用add_element方法把area加进来 $chart->add_element($area); $chart->set_bg_colour('#FFFFFF'); #设置label $x_labels = new x_axis_labels(); $x_labels->set_steps(1); $x_labels->set_colour('#A2ACBA'); $x_labels->set_labels($second); #设置X轴 $x_axis = new x_axis(); $x_axis->set_colour('#A2ACBA'); $x_axis->set_grid_colour('#D7E4A3'); $x_axis->set_offset(false); $x_axis->set_steps(1); $x_axis->set_labels($x_labels); $chart->set_x_axis($x_axis); #设置X轴的文件说明,即x_legend $legend_text = "当前网络流量 " . end($data) . $y_axis_key_text; $x_legend = new x_legend($legend_text); $x_legend->set_style('{font-size: 12px; color: #778877}'); $chart->set_x_legend($x_legend); #设置轴 $y_axis = new y_axis(); $y_axis->set_range(0, $y_axis_max, $y_axis_step); $y_axis->labels = null; $y_axis->set_offset(false); $chart->add_y_axis($y_axis); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); echo $chart->toPrettyString(); }
function subscription() { acymailing::setTitle(JText::_('CHARTS'), 'stats', 'diagram&task=subscription'); $listsClass = acymailing::get('class.list'); $lists = $listsClass->getLists('listid'); $db =& JFactory::getDBO(); $db->setQuery('SELECT min(subdate) as minsubdate, min(unsubdate) as minunsubdate FROM ' . acymailing::table('listsub')); $dates = $db->loadObject(); $spaces = array(); $intervals = 10; $dates->maxsubdate = time(); $delay = ($dates->maxsubdate - $dates->minsubdate) / $intervals; for ($i = 0; $i < $intervals; $i++) { $spaces[$i] = (int) ($dates->minsubdate + $delay * $i); } $spaces[$intervals] = $dates->maxsubdate; $results = array(); $legendX = array(); for ($i = 0; $i <= $intervals; $i++) { $legendX[] = acymailing::getDate($spaces[$i]); $db->setQuery('SELECT count(subid) as total, listid FROM ' . acymailing::table('listsub') . ' WHERE `status` != 2 AND `subdate` < ' . $spaces[$i] . ' AND (`status` = 1 OR `unsubdate`>' . $spaces[$i] . ') GROUP BY listid'); $results[$i] = $db->loadObjectList('listid'); } $title = new title(JText::_('SUB_HISTORY')); $title->set_style('font-size:20px; color: #FF8040'); $lines = array(); $maxSub = 0; foreach ($lists as $listid => $oneList) { $lines[$listid] = new line_base(); $values = array(); for ($i = 0; $i <= $intervals; $i++) { $values[] = empty($results[$i][$listid]->total) ? 0 : (int) $results[$i][$listid]->total; } $lines[$listid]->set_values($values); $lines[$listid]->set_text($oneList->name); $lines[$listid]->set_colour($oneList->color); $maxSub = max($maxSub, max($values)); } $x_axis = new x_axis(); $xlabelobject = new x_axis_labels(); $xlabelobject->rotate(-20); $xlabelobject->set_labels($legendX); $x_axis->set_labels($xlabelobject); $y_axis = new y_axis(); $y_axis->range(0, $maxSub, intval($maxSub / 10)); $chart = new open_flash_chart(); $chart->set_x_axis($x_axis); $chart->set_y_axis($y_axis); $chart->set_title($title); foreach ($lines as $oneLine) { $chart->add_element($oneLine); } $this->assignRef('chart', $chart); }
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(); }
function gsitedata() { $this->autoRender = false; $solid = $this->Session->read('sol'); $host_id = $this->Session->read('host_id'); $tinterval = 3600; $host_srch = ""; if (!empty($host_id) && $host_id != 0) { $host_srch = " AND source_id = " . $host_id; } $this->DnsMessage->recursive = -1; $site_count = $this->DnsMessage->query('SELECT hostname, COUNT(*) FROM dns_messages WHERE sol_id = ' . $solid . $host_srch . ' GROUP BY hostname ORDER BY COUNT(*) DESC LIMIT 50'); //sort($site_count); $data = array(); $x = array(); $max_resp = 0; foreach ($site_count as $site) { $data[] = array((int) $site[0]['COUNT(*)'], 0); if ($max_resp < (int) $site[0]['COUNT(*)']) { $max_resp = (int) $site[0]['COUNT(*)']; } if (empty($site[0]['hostname'])) { $x[] = (string) $site['dns_messages']['hostname']; } else { $x[] = (string) $site[0]['hostname']; } } // joson data format $title = new title(__("Host Popularity", true)); $title->set_style("{font-size: 14px; color: #990000; text-align: center; font-weight:bold;}"); $bar = new bar_stack(); $bar->set_colours(array('#e77919', '#577261')); $bar->set_on_show(new bar_on_show('grow-up', 0, 0.5)); $bar->set_values($data); $bar->set_tooltip('Host: #x_label#<br>Response #val#<br>'); $tooltip = new tooltip(); $tooltip->set_hover(); $tooltip->set_shadow(false); $tooltip->set_stroke(5); $tooltip->set_colour("#6E604F"); $tooltip->set_background_colour("#BDB396"); $data_labels = new x_axis_labels(); $data_labels->rotate(90); $data_labels->set_labels($x); $x_axis = new x_axis(); $x_axis->set_labels($data_labels); $y = new y_axis(); $y->set_range(0, $max_resp * 1.1, (int) ($max_resp / 10)); $chart = new open_flash_chart(); $chart->set_bg_colour('#F9F9F9'); $chart->set_title($title); $chart->add_element($bar); $chart->set_x_axis($x_axis); $chart->set_y_axis($y); $chart->set_tooltip($tooltip); // menu' $m = new ofc_menu("#f0E0ff", "#878787"); $m->values(array(new ofc_menu_item(__('DNS Response', true), 'go_gpage'))); $chart->set_menu($m); header("Content-Type: text/plain"); echo $chart->toPrettyString(); die; }
for ($m = $lookback_in_months; $m >= 0; $m--) { $ts = strtotime("-{$m} months"); if ($m == $lookback_in_months) { $time_lookback = strtotime(date('Y-m-01 00:00:00', $ts)); } $x_labels[] = date('M y', $ts); $x_values[date('Ym', $ts)] = 0; } //Query total unique mims moved to IN PROGRESS and grouped them monthly $q = "SELECT DATE_FORMAT(FROM_UNIXTIME(ish.status_time), '%Y%m') AS period" . ", COUNT(DISTINCT i.improvements_id) AS total_mims" . " FROM improvements i" . " INNER JOIN improvements_status_history ish" . " ON ish.improvements_id=i.improvements_id AND ish.status=3" . " WHERE i.department = {$team_id}" . " AND ish.status_time >= {$time_lookback}" . " GROUP BY period" . " ORDER BY period ASC"; $r = tep_db_query($q); while ($row = tep_db_fetch_array($r)) { $x_values[$row['period']] = intval($row['total_mims']); } $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
$db = NULL; $sql = NULL; // // This is the MODEL section: // include 'php-ofc-library/open-flash-chart.php'; // Make the chart $chart = new open_flash_chart(); // // Create a title object and set the text to todays date // //$title = new title( date("D M d Y") ); if (isset($e)) { $title = new title("Error: " . $e->getMessage()); } else { $title = new title("{$avg_min} Hours RVK Statistics"); } $title->set_style("{font-size: 20px; font-family: Courier; font-weight: bold; color: #A2ACBA; text-align: center;}"); // add the title to the chart: $chart->set_title($title); /* $m = new ofc_menu("#E0E0ff", "#707070"); $items[] = new ofc_menu_item('Refresh ','load'); $items[] = new ofc_menu_item('1 Hour ','show_hour1'); $items[] = new ofc_menu_item('2 Hours ','show_hour2'); $items[] = new ofc_menu_item('6 Hours ','show_hour3'); $items[] = new ofc_menu_item('12 Hours','show_hour4'); $items[] = new ofc_menu_item('1 Day ','show_hour5'); $items[] = new ofc_menu_item('3 Days ','show_hour6'); $items[] = new ofc_menu_item('1 Week ','show_hour7'); $items[] = new ofc_menu_item('2 Weeks ','show_hour8');
FROM ' . $table . ' a INNER JOIN M_RT b ON a.RTID=b.RTId WHERE a.RWID=' . $aRw[$_REQUEST['rwId']]['id'] . ' GROUP BY a.RTID, b.Nama ORDER BY b.Nama, a.RTID'; $result = mssql_query($sql); $data = array(); if (mssql_num_rows($result) > 0) { while ($val = mssql_fetch_assoc($result)) { $rt[] = 'RT ' . $val['RT']; $jumlah[] = $val['Jumlah']; $total = $val['total']; $tempJumlah = $val['Jumlah']; $maxJumlah = $maxJumlah > $tempJumlah ? $maxJumlah : $tempJumlah; } } $max = 0; $title = new title('Jumlah Data Peserta KB Per RT, RW ' . $aRw[$_REQUEST['rwId']]['nama'] . ' Total : ' . $total . ' ( ' . date("D M d Y") . ' ) '); $title->set_style('{font-size:15px; color: #bcd6ff; margin:0px; background-color: #5E83BF;}'); $bar = new bar_3d(); $bar->set_values($jumlah); $bar->colour = '#9999FF'; $bar->set_on_show(new bar_on_show('grow-up', 1, 0)); $labels = new x_axis_labels(); $labels->set_labels($rt); $y_base = new y_axis_base(); $y_base->set_range(0, $maxJumlah + round($maxJumlah / 2), round($maxJumlah / 10)); $x = new x_axis(); $x->set_labels($labels); $x->set_3d(5); $y = new y_axis(); $y->set_labels($y_labels); $tags = new ofc_tags();
function getField37Title() { //colocando todas as bibliotecas disponiveis na base na variavel collectionIssue $dataModel = new title(); $allData = $dataModel->getAllTitles(); $field37 = array(); for ($i = 0; $i < count($allData); $i++) { if ($allData[$i][37]) { array_push($field37, $allData[$i][37]); } } return array($field37); }
/** flowview_viewchart() * * This function is taken from Slowlog. Given * a title, chart type and chart data, it will * echo the required syntax for the Callback * from the chart page to operate corectly. */ function flowview_viewchart() { global $colors, $config; include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart-object.php"; include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart.php"; $title = $_REQUEST["title"]; $chart_type = "bar"; $column = $_REQUEST["type"]; $sessionid = $_REQUEST["session"]; /* get the chart data from the session */ if (isset($_SESSION['flowview_flows'][$sessionid]['data'])) { $data = $_SESSION['flowview_flows'][$sessionid]['data']; } else { $filter = createfilter($sessionid); $data = $_SESSION['flowview_flows'][$sessionid]['data']; } switch ($column) { case 'flows': $unit = ucfirst($column); $suffix = "Total Flows"; $_SESSION['sess_flows_flows'] = 'on'; break; case 'bytes': $unit = ucfirst($column); $suffix = "Bytes Exchanged"; $_SESSION['sess_flows_bytes'] = 'on'; break; case 'packets': $unit = ucfirst($column); $suffix = "Packets Examined"; $_SESSION['sess_flows_packets'] = 'on'; break; } $columns = $_SESSION['flowview_flows'][$sessionid]['columns']; foreach ($columns as $key => $cdata) { if (strtolower($cdata) == $column) { $column = $key; } } if (sizeof($data)) { $elements = array(); $legend = array(); $maxvalue = 0; if (isset($_REQUEST['exclude']) && $_REQUEST['exclude'] > 0) { for ($i = 0; $i < $_REQUEST['exclude']; $i++) { array_shift($data); } } foreach ($data as $row) { if ($maxvalue < $row[$column]) { $maxvalue = $row[$column]; $scaling = flowview_autoscale($row[$column]); } } $maxvalue = flowview_getmax($maxvalue); $autorange = flowview_autoscale($maxvalue); $maxvalue = $maxvalue / $autorange[0]; $i = 0; foreach ($data as $row) { $elements[$i] = new bar_value(round($row[$column] / $autorange[0], 3)); $elements[$i]->set_colour(flowview_get_color()); $elements[$i]->set_tooltip($unit . ": #val# " . $autorange[1]); if (sizeof($row) == 4) { $legend[] = $row[0]; } else { $legend[] = $row[0] . " -\n" . $row[1]; } $i++; } $bar = new bar_glass(); $bar->set_values($elements); $title = new title($title . " (" . $suffix . ")"); $title->set_style("{font-size: 18px; color: #444444; text-align: center;}"); $x_axis_labels = new x_axis_labels(); $x_axis_labels->set_size(10); $x_axis_labels->rotate(45); $x_axis_labels->set_labels($legend); $x_axis = new x_axis(); //$x_axis->set_3d( 3 ); $x_axis->set_colours('#909090', '#909090'); $x_axis->set_labels($x_axis_labels); $y_axis = new y_axis(); $y_axis->set_offset(true); $y_axis->set_colours('#909090', '#909090'); $y_axis->set_range(0, $maxvalue, $maxvalue / 10); $y_axis->set_label_text("#val# " . $autorange[1]); $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); $chart->set_bg_colour('#FEFEFE'); echo $chart->toString(); } }
/** * 工作耗时饼猪状图 *@param $id 传入的项目ID *@examlpe */ public function buglevel($id) { $Public = A('Index', 'Public'); $App = A('App', 'Public'); Vendor('OpenFlash.open-flash-chart'); //main $Report = M('Report_table'); $id = intval($id); $color = array('#99C754', '#54C7C5', '#999999', '#996699', '#009900', '#77C600', '#ff7400', '#FF0000', '#4096ee', '#c79810'); $level = $App->getJson('yanzhongxing', '/Linkage'); $info = $Report->field('level,COUNT(id) as num')->where('pid=' . $id)->group('level')->order('level')->select(); //dump($info); $title = new title(); $title->set_style("font-size:13px; font-weight:bold;"); $pie = new pie(); $pie->set_alpha(0.8); $pie->start_angle(35); $pie->add_animation(new pie_fade()); $pie->add_animation(new pie_bounce(5)); $pie->gradient_fill(); $pie->set_tooltip('数量:#val#条, 占:#percent#'); $pie->set_colours($color); foreach ($info as $k => $t) { $obj = new pie_value(intval($t['num']), ''); $name = $Public->searchArr($level, 'id', $t['level']); $obj->set_label($name . ':' . $t['num'] . '条', $color[$k], 12); $dis_value[] = $obj; } //dump($dis_value); $pie->set_values($dis_value); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($pie); $chart->x_axis = null; $chart->bg_colour = '#FFFFFF'; echo $chart->toPrettyString(); }
function build() { //set chart title $chart_title = new title($this->title); $chart_title->set_style('font-size:' . $this->title_size . 'px; color:' . $this->title_color . ';font-weight:bold;'); $this->chart->set_title($chart_title); //set chart bg color $this->chart->set_bg_colour($this->bg_colour); //set chart legend $this->chart->set_y_legend($this->y_legend); $this->chart->set_x_legend($this->x_legend); //add elements to chart foreach ($this->elements as $key => $value) { $this->chart->add_element($value); } $this->nvd3_chart->setPlaceholder($this); $this->nvd3_chart->create_dataseries($this); //Axis definition switch ($this->type) { case self::BAR_HORIZONTAL: //Increase max value for better chart's look and feel //$this->x_axis_max_val += $this->x_axis_step; /*** X AXIS ***/ $this->x_axis->set_colour($this->x_axis_color); $this->x_axis->set_grid_colour($this->x_axis_grid_color); $this->x_axis->set_stroke($this->x_axis_thickness); //If labels are defined if ($this->x_axis_labels != NULL) { $this->x_axis->set_range(0, sizeof($this->x_axis_labels->labels) - 1); $this->x_axis->set_offset(false); $this->x_axis_labels->rotate($this->x_axis_labels_rotation); $this->x_axis->set_labels($this->x_axis_labels); $this->chart->set_x_axis($this->x_axis); } else { //Set default labels //No labels will be added; it's a trick to give style to labels assigned with set_range. $this->x_axis_labels = new x_axis_labels(); $this->x_axis_labels->set_colour($this->x_axis_labels_color); $this->x_axis_labels->set_size($this->x_axis_labels_size); $this->x_axis_labels->rotate($this->x_axis_labels_rotation); $this->x_axis->set_labels($this->x_axis_labels); //End trick $this->x_axis->set_range(0, $this->x_axis_max_val); $this->x_axis->set_steps($this->x_axis_step); $this->chart->set_x_axis($this->x_axis); } /*** Y AXIS ***/ $this->y_axis->set_stroke($this->y_axis_thickness); $this->y_axis->set_colour($this->y_axis_color); $this->y_axis->set_grid_colour($this->y_axis_grid_color); //If labels are defined if ($this->y_axis_labels != NULL) { $this->y_axis->set_range(0, sizeof($this->y_axis_labels->labels) - 1); $this->y_axis->set_offset(true); //$this->y_axis_labels->rotate($this->y_axis_labels_rotation); //******************* $this->y_axis->set_labels($this->y_axis_labels); $this->chart->set_y_axis($this->y_axis); } else { //Set default labels $this->y_axis->set_range(0, $this->y_axis_max_val - 1); $this->y_axis->set_offset(true); $this->chart->set_y_axis($this->y_axis); $this->y_axis->set_range($this->y_axis_min_val < 0 ? $this->y_axis_min_val : 0, $this->y_axis_max_val, $this->y_axis_step); $this->chart->set_y_axis($this->y_axis); } break; case self::DONUT: case self::PIE: break; case self::RADAR: //Increase max value for better chart's look and feel //$this->y_axis_max_val += $this->y_axis_step; /*** Y AXIS ***/ //overwrite axis definition $this->y_axis = new radar_axis($this->y_axis_max_val); $this->y_axis->set_spoke_labels($this->y_axis_labels); $this->y_axis->set_steps($this->y_axis_step); $this->y_axis->set_colour($this->y_axis_color); $this->y_axis->set_grid_colour($this->y_axis_grid_color); $this->chart->set_radar_axis($this->y_axis); $this->y_axis->set_stroke($this->y_axis_thickness); break; default: //Increase max value for better chart's look and feel //$this->y_axis_max_val += $this->y_axis_step; //$this->y_axis_max_val += $this->y_axis_step; /*** X AXIS ***/ $this->x_axis->set_grid_colour($this->x_axis_grid_color); $this->x_axis->set_colour($this->x_axis_color); //thickness and offset switch ($this->type) { case self::LINE: $this->x_axis->set_offset(false); break; case self::STACKED_AREA: case self::LINE_AREA: $this->x_axis->set_offset(false); break; case self::BAR_3D: $this->x_axis->set_3d($this->x_axis_thickness); break; case self::BAR_CYLINDER: $this->x_axis->set_3d($this->x_axis_thickness); break; case self::BAR_CYLINDER_OUTLINE: $this->x_axis->set_3d($this->x_axis_thickness); break; case self::BAR_DOME: $this->x_axis->set_3d($this->x_axis_thickness); break; case self::BAR_ROUND_3D: $this->x_axis->set_3d($this->x_axis_thickness); break; default: $this->x_axis->set_stroke($this->x_axis_thickness); break; } //If labels are defined $this->x_axis->set_colour($this->x_axis_color); if ($this->x_axis_labels != NULL) { $this->x_axis_labels->rotate($this->x_axis_labels_rotation); $this->x_axis->set_labels($this->x_axis_labels); $this->chart->set_x_axis($this->x_axis); } else { //Set default labels //No labels will be added; it's a trick to give style to labels assigned with set_range. $this->x_axis_labels = new x_axis_labels(); $this->x_axis_labels->set_colour($this->x_axis_labels_color); $this->x_axis_labels->set_size($this->x_axis_labels_size); $this->x_axis_labels->rotate($this->x_axis_labels_rotation); $this->x_axis->set_labels($this->x_axis_labels); //End trick $this->chart->set_x_axis($this->x_axis); } /*** Y AXIS ***/ $this->y_axis->set_stroke($this->y_axis_thickness); $this->y_axis->set_colour($this->y_axis_color); $this->y_axis->set_grid_colour($this->y_axis_grid_color); //If labels are defined if ($this->y_axis_labels != NULL) { $this->y_axis->set_labels($this->y_axis_labels); $this->chart->set_y_axis($this->y_axis); } else { //Set default labels //No labels will be added; it's a trick to give style to labels assigned with set_range. $this->y_axis_labels = new y_axis_labels(); $this->y_axis_labels->set_colour($this->y_axis_labels_color); $this->y_axis_labels->set_size($this->y_axis_labels_size); $this->y_axis_labels->rotate($this->y_axis_labels_rotation); $this->y_axis->set_labels($this->y_axis_labels); //End trick $this->y_axis->set_range($this->y_axis_min_val < 0 ? $this->y_axis_min_val : 0, $this->y_axis_max_val, $this->y_axis_step); $this->chart->set_y_axis($this->y_axis); } break; } }
$sent = 0; $package = 0; } //$y_max = max(array($sourcing, $open, $start, $finish, $package, $sent)); $y_max = max(array($sourcing, $start, $ready, $pullrack, $workshop, $ampol, $lab, $finish, $package, $sent)); if ($y_max < 100) { $y_max = 100; } $step = $y_max < 1000 ? 50 : round($y_max / 1000) * 100; if ($y_max > 100) { $y_max += $fullscreen ? 2 * $step : $step; } if ($fullscreen) { $yfs = $y_max >= 1000 ? 16 : ($y_max >= 500 ? 20 : 30); } $title = new title("{$header_title}"); $title->set_style("{font-size:" . $hfs . "px; font-weight:bold; color:#000, bottom:20px;}"); //$data = array('SOURCING'=>intval($sourcing), 'NEW'=>intval($start), 'OPEN'=>intval($open), 'FINISH'=>intval($finish), 'IN PACKAGE'=>intval($package), 'SENT TO HH'=>intval($sent)); $data = array('SOURCING' => intval($sourcing), 'NEW' => intval($start), 'READY' => intval($ready), 'PULLRACK' => intval($pullrack), 'SOLDER SETTING' => intval($workshop), 'AMPOL AND QC' => intval($ampol), 'LAB' => intval($lab), 'FINISH' => intval($finish), 'IN PACKAGE' => intval($package), 'SENT TO HH' => intval($sent)); if ($bar_selected != '') { $dt = array(); foreach ($bar_selected as $data_key) { if ($fullscreen) { //translate textbar to indonesian //$bar_to_translate = array('NEW', 'READY', 'PULLRACK', 'FINISH'); $bar_to_translate = array(); if (in_array($data_key, $bar_to_translate)) { if ($data_key == 'NEW') { $dt['BARU'] = $data[$data_key]; } elseif ($data_key == 'READY') { $dt['AKAN DATANG'] = $data[$data_key];
function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '') { $this->load->library('ofc'); $userId = $this->common->getUserId(); $this->ofc->open_flash_chart(); $this->ofc->set_bg_colour(CHART_BG_COLOR); $toTime = date("Y-m-d", strtotime("-1 day")); if ($timePhase == "7day") { $fromTime = date("Y-m-d", strtotime("-8 day")); $color = CHART_LINE_1; $key = "近7日新增用户"; $title = new title("近7日新增用户统计"); } if ($timePhase == "1month") { $title = new title("近30天新增用户统计"); $fromTime = date("Y-m-d", strtotime("-31 day")); $color = CHART_LINE_2; $key = "近30天新增用户统计"; } if ($timePhase == "3month") { $title = new title("近三个月新增用户统计"); $fromTime = date("Y-m-d", strtotime("-92 day")); $color = CHART_LINE_3; $key = "近三个月新增用户统计"; } if ($timePhase == "all") { $title = new title("所有新增用户统计"); $fromTime = '1970-01-01'; $color = CHART_LINE_4; $key = "所有新增用户统计"; } if ($timePhase == "any") { $title = new title("所有新增用户统计"); $fromTime = $fromDate; $toTime = $toDate; $color = CHART_LINE_4; $key = "所有新增用户统计"; } $fromTime = $this->product->getUserStartDate($userId, $fromTime); $query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId); $data = array(); $maxY = 0; $recordCount = $query->num_rows(); $steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10); $xlabelArray = array(); if ($query != null && $query->num_rows() > 0) { foreach ($query->result() as $row) { $dot = new dot(); $dot->size(3)->halo_size(1)->colour($color); $dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户"); $dot->value((int) $row->totalusers); if ((int) $row->totalusers > $maxY) { $maxY = (int) $row->totalusers; } array_push($xlabelArray, date('y-m-d', strtotime($row->startdate))); array_push($data, $dot); } } $y = new y_axis(); $y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY)); $x = new x_axis(); $x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1); $x_labels = new x_axis_labels(); $x_labels->set_steps($steps); $x_labels->set_vertical(); $x_labels->set_colour(CHART_LABEL_COLOR); $x_labels->set_size(13); $x_labels->set_labels($xlabelArray); $x_labels->rotate(-25); $x->set_labels($x_labels); $x->set_steps(1); $this->ofc->set_y_axis($y); $this->ofc->set_x_axis($x); $dot = new dot(); $dot->size(3)->halo_size(1)->colour($color); $line = new line(); $line->set_default_dot_style($dot); $line->set_values($data); $line->set_width(2); $line->set_colour($color); $line->colour($color); $line->set_key($key, 12); $this->ofc->add_element($line); $title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}"); // $x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>"); // $this->ofc->set_x_legend( $x_legend ); // $x_legend->set_style( '{font-size: 14px; color: #778877}' ); $this->ofc->set_title($title); echo $this->ofc->toPrettyString(); }
$ofc_path = "../../include/ofc-2-Kvasir/php-ofc-library"; include "{$ofc_path}/open-flash-chart.php"; $d = array(); $rads = $alertaVerde + $alertaRoja + $alertaAmarilla; //echo "$alertaVerde + $alertaRoja + $alertaAmarilla <hr>"; $d[] = new pie_value(round($alertaVerde), "<10"); $d[] = new pie_value(round($alertaRoja), "<0"); $slice = new pie_value(round($alertaAmarilla), ">10"); $slice->on_click('http://'); $d[] = $slice; if (!$rads) { $rads = 1; } $d[] = new pie_value(1 * 100 / $rads, ""); $pie = new pie(); $title = new title('Estado de Radicados En Bandeja'); $title->set_style("{font-size: 9px; color: #F24062; text-align: center;}"); $pie->set_animate(true); $pie->set_label_colour('#432BAF'); $pie->set_alpha(1); $pie->set_start_angle(0); $pie->add_animation(new pie_fade()); $pie->set_tooltip('#label#<br>Numero de Radicados #val# (#percent#)'); // // default on-click event // $pie->on_click('pie_slice_clicked'); // // // $pie->set_colours(array('#77CC6D', '#f9022b', '#f6ed05'));
echo '[' . mysql_errno() . ']' . PHP_EOL . mysql_error() . PHP_EOL; echo $ok . PHP_EOL . $stmt; exit; } else { while ($row = mysql_fetch_object($ok)) { $time_axis[] = date("H:i", strtotime($row->Time)); $data_watt[] = round((double) $row->Watt, 3); //$data_max[] = round((float)$row->maxWatt,3) ; $data_tot[] = round((double) $row->ETotal, 3); } $chart = new open_flash_chart(); if (count($time_axis) == 0) { echo 0; exit; } $title = new title("\n" . date('l dS F Y', $time) . " (" . round(max($data_tot) - min($data_tot), 2) . " kWh)"); $title->set_style('{font-size: 20px; color: #778877;}'); $tooltip = new tooltip(); $tooltip->set_hover(); $sline = new scatter_line('#3D3D3D', 3); $def = new hollow_dot(); $def->size(0)->halo_size(0); $sline->set_default_dot_style($def); $sline->set_key('Leistung (W)', 11); $v = array(); foreach ($data_watt as $key => $val) { $v[] = new scatter_value($key, $val); $v[] = new scatter_value($key + 1, $val); } $sline->set_values($v); $bars_curr = new bar_glass();
} $date_count++; } // line properties $d = new hollow_dot(); $d->size(5)->halo_size(0)->colour('#3D5C56'); $line->set_default_dot_style($d); $line->set_values($returns); $line->set_width(2); $line->set_colour('#668053'); $chart->add_element($line); // title properties $portfolio_type = array("", "Unknown", "401(k)", "Traditional IRA", "Roth IRA", "SIMPLE IRA", "SEP-IRA", "Solo 401(k)", "Roth 401(k)", "403(b)", "Other"); $type_idx = $_GET['i']; $type_idx = $type_idx == 0 ? $type_idx : $type_idx - 1; $title = new title("Individual Portfolio Performance (" . $portfolio_type[$type_idx] . ")"); $title->set_style("{font-size: 25px; font-family: Calibri; font-weight: bold; color: #121212; text-align: center;}"); $chart->set_title($title); // y axis properties $y = new y_axis(); $y_min = 0.0; $y_max = 0.0; $y_min = floor(0.995 * $amt_min); $y_max = ceil(1.005 * $amt_max); $y->set_grid_colour('#EFEFEF'); $y->set_range($y_min, $y_max, round(($y_max - $y_min) / 5.0)); $chart->set_y_axis($y); // y legend properties $y_legend = new y_legend('Amount ($)'); $y_legend->set_style('{font-size:15px; font-family:Calibri; color:#121212}'); $chart->set_y_legend($y_legend);
public function setTitle($text, $css) { $title = new title($text); $title->set_style($css); $this->chart->set_title($title); }
<?php die('<p style="font-size:36px;color:black;font-weight:bold;">404!</p>'); /*************************************************************************************** * определяем title, keywords, description, h1 ***************************************************************************************/ // получаем метатеги для текущего контроллера $_arr = dbh::get_title(); // инициализируем класс $title = new title(); if ($_arr) { // устанавливаем свойства $title->title = NAME_FIRMS . ' - ' . $_arr['title']; $_arr['keywords'] != '' ? $title->keywords = $_arr['keywords'] : ($title->keywords = $_arr['title']); $_arr['description'] != '' ? $title->description = $_arr['description'] : ($title->description = $_arr['title']); $_arr['h1'] != '' ? $title->h1 = $_arr['h1'] : ($title->h1 = $_arr['title']); } /*************************************************************************************** ***************************************************************************************/ global $_str; // check for crack! if (isset($_GET['page'])) { system::count_parametr(4); system::isset_numeric($_GET['page']); } else { system::count_parametr(3); $_GET['page'] = 1; } // добавление новости if (system::IsPost()) { if (!captcha::check_captcha()) { //выводим сообщение
$q .= " AND o.orders_status<=10"; $q .= " UNION ALL"; $sp_active = $class_sp->retrieveList(); //Products sold on sp's $q .= " SELECT jo.order_date, joi.order_quantity AS products"; $q .= " FROM jng_sp_orders jo"; $q .= " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id"; $q .= " WHERE jo.jng_sp_id IN (" . implode(',', array_keys($sp_active)) . ") AND jo.order_date>=DATE_SUB(CURRENT_DATE(), INTERVAL {$days} DAY) AND joi.status NOT IN (10,12)"; $q .= ")dt ORDER BY order_date"; $res = tep_db_query($q); while ($r = tep_db_fetch_array($res)) { $p = date($format_date, strtotime($r['order_date'])); $bar_values[$p] += $r['products']; } //Start constructing charts $title = new title('Last ' . $days . ' Days Sales Chart'); $title->set_style("{font-size:14px; font-weight:bold; padding:10px;}"); $chart = new open_flash_chart(); $chart->set_title($title); $area = new area(); $area->set_colour('#5B56B6'); $area->set_values(array_values($bar_values)); $area->set_key('Products', 12); $chart->add_element($area); //define x-axis $x_labels = new x_axis_labels(); $x_labels->set_steps(4); $x_labels->set_labels($period); $x = new x_axis(); $x->set_grid_colour('#D7E4A3'); //$x->set_offset($period_offset);
function generateStats($params) { global $reportCacheLocation; // Computer Statistics Generation $dbTrackHandler = connectDb(); $resultBag = generateStatsBag($params, $dbTrackHandler); // ---------------------------------------------------- // Generate charts $animation_1 = isset($params['animation_1']) ? $params['animation_1'] : 'pop'; $delay_1 = isset($params['delay_1']) ? $params['delay_1'] : 0.5; $cascade_1 = isset($params['cascade_1']) ? $params['cascade_1'] : 1; $title = new title("Genie Report: " . $params['reportName'] . " - Generated on " . date('Y/m/d h:i:s A')); $title->set_style("{font-size: 12px; color: #000000; text-align: center;}"); $bar_stack = new bar_stack(); if ($params['reportType'] == 'computerStats') { foreach ($resultBag as $elm) { $tmpTotal = $elm[AVAIBILITY_TYPE_OFFLINE] + $elm[AVAIBILITY_TYPE_AVAILABLE] + $elm[AVAIBILITY_TYPE_BUSY]; if ($tmpTotal == 0) { $tmpTotal = 1; } // Only Chuck Norris can divide by Zero. $bar_stack->append_stack(array($elm[AVAIBILITY_TYPE_OFFLINE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_AVAILABLE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_BUSY] / $tmpTotal * 100)); } $bar_stack->set_colours(array('#FF0000', '#00FF00', '#A25B00')); $bar_stack->set_keys(array(new bar_stack_key('#FF0000', 'OFFLINE', 13), new bar_stack_key('#00FF00', 'FREE', 13), new bar_stack_key('#A25B00', 'BUSY', 13))); } else { $allProgNames = array(); foreach ($resultBag as $elm) { $progNames = array_keys($elm); foreach ($progNames as $progName) { if (validProgram($progName)) { if (!array_key_exists($progName, $allProgNames)) { $allProgNames[$progName] = "#" . dechex(rand(0, 10000000)); } } } } $progsArray = array(); foreach ($resultBag as $elm) { $tmpTotal = 0; $progNames = array_keys($elm); foreach ($elm as $programName => $programWeight) { if (validProgram($programName)) { $tmpTotal += $programWeight; } } //echo "<h1>$tmpTotal</h1>"; if ($tmpTotal == 0) { $tmpTotal = 1; } // Only Chuck Norris can divide by Zero. $progs = array(); foreach ($elm as $programName => $programWeight) { if (validProgram($programName)) { $percentVal = $programWeight / $tmpTotal * 100; $progs[] = new bar_stack_value($percentVal, $allProgNames[$programName]); $progsArray[$percentVal * 1000000] = $programName; } } $bar_stack->append_stack($progs); } $legends = array(); //$strAllProgNames = array_keys($allProgNames); foreach ($allProgNames as $programName => $programColor) { $legends[] = new bar_stack_key($programColor, $programName, 13); } $bar_stack->set_keys($legends); ksort($progsArray); echo "<pre>"; while (list($key, $value) = each($progsArray)) { $kw = $key / 1000000; echo "{$kw}: {$value}<br />\n"; } echo "</pre>"; } //$bar_stack->set_tooltip( 'In #x_label# you get #total# days holiday a year.<br>Number of days: #val#' ); $bar_stack->set_on_show(new bar_on_show($animation_1, $cascade_1, $delay_1)); $y = new y_axis(); $y->set_range(0, 100, 10); //$y->set_range( 0, $tmpMax, $tmpMax/10 ); $x_labels = new x_axis_labels(); $x_labels->rotate(45); $x_labels->set_labels(array_keys($resultBag)); $x = new x_axis(); $x->set_labels($x_labels); $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); // ---------------------------------------------------- $cacheid = time(); $filename = $cacheid . '.cache.json'; $myFile = "{$reportCacheLocation}/reports-cache/" . $filename; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $chart->toPrettyString()); fclose($fh); return $cacheid; }