private function show_day_information($type, $date) { $filter = new filter($this->db, $this->output, $this->user); $filter->to_output($this->model->table, $this->model->hostnames); if (($stats = $this->model->get_day_statistics($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $graph = new graph($this->output); $graph->title = $this->graphs[$type] . " for " . date("l j F Y", strtotime($date)); $graph->width = 960; $graph->height = GRAPH_HEIGHT; foreach ($stats as $hour => $count) { $graph->add_bar("Hour " . $hour, $count, "hour"); } $graph->to_output(); if (($stats = $this->model->get_day_information($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $this->output->open_tag("day", array("hostnames" => show_boolean($this->model->hostnames), "label" => $this->graphs[$type])); foreach ($stats as $stat) { if ($type == "requests" || $type == "bytes_sent") { $stat["count"] = $this->model->readable_number($stat["count"]); } $this->output->record($stat, "stat"); } $this->output->close_tag(); }
function render($id, $title) { global $path_to_root; include_once $path_to_root . "/includes/ui.inc"; include_once $path_to_root . "/reporting/includes/class.graphic.inc"; if (!defined('FLOAT_COMP_DELTA')) { define('FLOAT_COMP_DELTA', 0.004); } if (!isset($this->top)) { $this->top = 10; } $begin = begin_fiscalyear(); $today = Today(); $begin1 = date2sql($begin); $today1 = date2sql($today); $sql = "SELECT SUM((trans.ov_amount + trans.ov_discount) * rate) AS total, s.supplier_id, s.supp_name FROM\n " . TB_PREF . "supp_trans AS trans, " . TB_PREF . "suppliers AS s WHERE trans.supplier_id=s.supplier_id\n AND (trans.type = " . ST_SUPPINVOICE . " OR trans.type = " . ST_SUPPCREDIT . ")\n AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}' "; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= "GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id " . " LIMIT " . $this->top; $result = db_query($sql); if ($this->graph_type == 'Table') { $th = array(_("Supplier"), _("Amount")); start_table(TABLESTYLE, "width=98%"); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $name = $myrow["supplier_id"] . " " . $myrow["supp_name"]; label_cell($name); amount_cell($myrow['total']); end_row(); } end_table(1); } else { $pg = new graph(); $i = 0; while ($myrow = db_fetch($result)) { $name = $myrow["supplier_id"] . " " . $myrow["supp_name"]; $pg->x[$i] = $name; $pg->y[$i] = $myrow['total']; $i++; } $pg->title = $title; $pg->axis_x = _("Supplier"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $today; $pg->type = 2; $pg->skin = 1; $pg->built_in = false; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>"; } }
function render($id, $title) { global $path_to_root; include_once $path_to_root . "/reporting/includes/class.graphic.inc"; if (!defined('FLOAT_COMP_DELTA')) { define('FLOAT_COMP_DELTA', 0.004); } if (!isset($this->top)) { $this->top = 10; } $begin = begin_fiscalyear(); $today = Today(); $begin1 = date2sql($begin); $today1 = date2sql($today); $sql = "SELECT SUM((ov_amount + ov_discount) * rate * IF(trans.type = " . ST_CUSTCREDIT . ", -1, 1)) AS total,d.debtor_no, d.name" . " FROM " . TB_PREF . "debtor_trans AS trans, " . TB_PREF . "debtors_master AS d" . " WHERE trans.debtor_no=d.debtor_no" . " AND (trans.type = " . ST_SALESINVOICE . " OR trans.type = " . ST_CUSTCREDIT . ")" . " AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}'"; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= " GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no " . " LIMIT " . $this->top; $result = db_query($sql); if ($this->graph_type == 'Table') { $th = array(null, _("Customer"), _("Amount")); start_table(TABLESTYLE, "width=98%"); table_header($th); $k = 0; //row colour counter $i = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell(viewer_link($myrow["debtor_no"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"])); label_cell(viewer_link($myrow["name"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"])); amount_cell($myrow['total']); end_row(); } end_table(1); } else { $pg = new graph(); $i = 0; while ($myrow = db_fetch($result)) { $pg->x[$i] = $myrow["debtor_no"] . " " . $myrow["name"]; $pg->y[$i] = $myrow['total']; $i++; } $pg->title = $title; $pg->axis_x = _("Customer"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $today; $pg->type = 2; $pg->skin = 1; $pg->built_in = false; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>"; } }
function render($id, $title) { global $path_to_root; include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $begin = begin_fiscalyear(); $today = Today(); $begin1 = date2sql($begin); $today1 = date2sql($today); $sql = "SELECT SUM(amount) AS total, c.class_name, c.ctype FROM\n " . TB_PREF . "gl_trans," . TB_PREF . "chart_master AS a, " . TB_PREF . "chart_types AS t,\n " . TB_PREF . "chart_class AS c WHERE\n account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid\n AND IF(c.ctype > 3, tran_date >= '{$begin1}', tran_date >= '0000-00-00')\n AND tran_date <= '{$today1}' "; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= " GROUP BY c.cid ORDER BY c.cid"; $result = db_query($sql, "Transactions could not be calculated"); $calculated = _("Calculated Return"); if ($this->graph_type == 'Table') { start_table(TABLESTYLE2, "width=98%"); $total = 0; while ($myrow = db_fetch($result)) { if ($myrow['ctype'] > 3) { $total += $myrow['total']; $myrow['total'] = -$myrow['total']; } label_row($myrow['class_name'], number_format2($myrow['total'], user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right"); } label_row(" ", ""); label_row($calculated, number_format2(-$total, user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right"); end_table(1); } else { $pg = new graph(); $i = 0; $total = 0; while ($myrow = db_fetch($result)) { if ($myrow['ctype'] > 3) { $total += $myrow['total']; $myrow['total'] = -$myrow['total']; $pg->x[$i] = $myrow['class_name']; $pg->y[$i] = abs($myrow['total']); $i++; } } $pg->x[$i] = $calculated; $pg->y[$i] = -$total; $pg->title = $title; $pg->axis_x = _("Class"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $today; $pg->type = 5; $pg->skin = 1; $pg->built_in = false; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>"; } }
function render($id, $title) { global $path_to_root; if (!isset($this->top)) { $this->top = 10; } global $path_to_root; $pg = new graph(); $begin = begin_fiscalyear(); $today = Today(); $begin1 = date2sql($begin); $today1 = date2sql($today); $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM\n " . TB_PREF . "gl_trans AS t," . TB_PREF . "dimensions AS d WHERE\n (t.dimension_id = d.id OR t.dimension2_id = d.id) AND\n t.tran_date >= '{$begin1}' AND t.tran_date <= '{$today1}' "; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= "GROUP BY d.id ORDER BY total DESC LIMIT " . $this->top; $result = db_query($sql, "Transactions could not be calculated"); if ($this->graph_type == 'Table') { $title = _("Top 10 Dimensions in fiscal year"); br(2); display_heading($title); br(); $th = array(_("Dimension"), _("Amount")); start_table(TABLESTYLE, "width=98%"); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow['reference'] . " " . $myrow["name"]); amount_cell($myrow['total']); end_row(); } end_table(2); } else { $pg = new graph(); $i = 0; while ($myrow = db_fetch($result)) { $pg->x[$i] = $myrow['reference'] . " " . $myrow["name"]; $pg->y[$i] = abs($myrow['total']); $i++; } $pg->title = $title; $pg->axis_x = _("Dimension"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $today; $pg->type = 5; $pg->skin = 1; $pg->built_in = false; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>"; } }
public function execute() { $graph = new graph($this->output); $graph->title = "Demo graph"; $graph->width = 600; $graph->height = 200; $nr = 1; for ($i = 0; $i < 6.3; $i += 0.1) { $graph->add_bar("Bar number: " . $nr++, sprintf("%0.2f", sin($i) + 1.5)); } $graph->to_output(); }
function grafico($titulo) { $this->load->library('Graph'); $mSQL_1 = "SELECT cod_cli,nombre, \r\n\t\t\tsum(totalg*IF(tipo_doc='D', -1, 1)) AS grantotal, \r\n\t\t\tsum(totalg*(referen IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) AS contado,\r\n\t\t\tsum(totalg*(referen NOT IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) AS credito \r\n\t\t\tFROM sfac\r\n\t\t\tWHERE tipo_doc<>'X' AND fecha>='20070101' AND fecha<='20071231' \r\n\t\t\tGROUP BY cod_cli ORDER BY grantotal DESC LIMIT 10"; // generate some random data srand((double) microtime() * 1000000); $bar_1 = new bar_fade(50, '#209B2C'); $bar_1->key('Contado', 10); $bar_2 = new bar_fade(50, '#9933CC'); $bar_2->key('Credito', 10); $bar_3 = new bar_fade(50, '#639F45'); $bar_3->key('Total', 10); $maxval = 0; $label = $tips = array(); $query = $this->db->query($mSQL_1); foreach ($query->result() as $row) { if ($row->grantotal > $maxval) { $maxval = $row->grantotal; } $bar_1->data[] = $row->contado; $bar_2->data[] = $row->credito; $bar_3->data[] = $row->grantotal; //$bar_1->tips = $data_tips_3; $tips[] = $row->nombre; $label[] = $row->cod_cli; } $g = new graph(); $g->title($titulo, '{font-size: 26px;}'); $g->data_sets[] = $bar_1; $g->data_sets[] = $bar_2; $g->data_sets[] = $bar_3; $g->set_x_labels($label); $g->set_x_label_style(10, '#9933CC', 2, 1); $g->set_x_axis_steps(10); $g->bg_colour = '#FFFFFF'; $g->set_tool_tip('#key#<br>Codigo de Clinte: #x_label# <br>Monto: #tip#'); $g->tips = $tips; $g->set_y_max($maxval); $g->y_label_steps(3); $g->set_y_legend('Open Flash Chart', 12, '0x736AFF'); echo utf8_encode($g->render()); }
function mkCacheData($date_from, $date_to, $product_id) { $conditions = array(); $info = $this->dbstuff->GetRow("SELECT * FROM " . $this->table_prefix . "products WHERE id='" . $product_id . "'"); if (!empty($info)) { $_GET['pn'] = $info['name']; } $mdt = date("Ymd") . "_" . substr(md5($_GET['pn'] . $_GET['ds'] . $_GET['de']), 0, 6); $file_item = $mdt; $file_path = DATA_PATH . "tmp/" . $file_item . $this->cache_ext; if (!file_exists($file_path)) { // use the chart class to build the chart: include_once LIB_PATH . 'ofc/chart.php'; $g = new graph(); $result = $this->dbstuff->GetArray("SELECT DATE_FORMAT(FROM_UNIXTIME(created),'%m') as mn,avg(max_price) AS avmax,avg(min_price) AS avmin FROM " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to} group by mn ORDER BY created ASC"); if (!empty($result)) { foreach ($result as $val) { $data[] = floor(($val['avmax'] + $val['avmin']) / 2); } $title = L("stat_charts", "tpl") . $_GET['ds'] . L("arrive_to", "tpl") . $_GET['de']; } elseif ($info['name']) { $title = $info['name']; } else { $title = L("data_not_exists") . df(); } $g->title($title, '{font-size: 24px;color: #0000FF}'); $g->set_data($data); $g->line_hollow(2, 4, '0x80a033', $_GET['pn'], 10); // label each point with its value //$g->set_x_labels( explode(",", L("months", "tpl")) ); $x_result = $this->dbstuff->GetArray("select CONCAT(FROM_UNIXTIME(created, '%Y'),'/',FROM_UNIXTIME(created, '%m')) as m from " . $this->table_prefix . "quotes WHERE created BETWEEN {$date_from} AND {$date_to} group by DATE_FORMAT(FROM_UNIXTIME(created),'%m') ORDER BY created ASC"); foreach ($x_result as $val) { $x_tmp[] = $val['m']; } $g->set_x_labels($x_tmp); $label_y = $this->dbstuff->GetRow("select max(max_price) as price_max,min(min_price) as price_min from " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to}"); $y_max = !empty($label_y['price_max']) ? $label_y['price_max'] : 100; // set the Y max $this->max_price = $label_y['price_max']; $this->min_price = $label_y['price_min']; $g->set_y_max($label_y['price_max']); // label every 20 (0,20,40,60) $g->y_label_steps(6); // display the data file_put_contents($file_path, $g->render()); } $this->cache_datafile = $file_item . $this->cache_ext; }
function grafico($anio = '') { $this->load->library('Graph'); if (empty($anio)) { return; } $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $mSQL = "SELECT a.vd, LEFT(b.nombre, 8)as nombre2, \n\t\t sum(a.totalg*IF(a.tipo_doc='D', -1, 1)) AS grantotal, \n\t\t sum(a.totalg*(a.referen IN ('E', 'M'))*IF(a.tipo_doc='D', -1, 1)) AS contado, \n\t\t sum(a.totalg*(a.referen NOT IN ('E', 'M'))*IF(a.tipo_doc='D', -1, 1)) AS credito \n\t\t FROM sfac AS a \n\t\t JOIN vend AS b ON a.vd=b.vendedor \n\t\t WHERE a.tipo_doc<>'X' AND a.fecha>='{$fechai}' AND a.fecha<='{$fechaf}' \n\t\t GROUP BY a.vd ORDER BY a.vd,grantotal DESC LIMIT 10"; $maxval = 0; $query = $this->db->query($mSQL); $data_1 = $data_2 = $data_3 = $vendedor = array(); foreach ($query->result() as $row) { if ($row->grantotal > $maxval) { $maxval = $row->grantotal; } $nombre[] = $row->nombre2; $vendedor[] = $row->vd; $data_1[] = $row->contado; $data_2[] = $row->credito; $data_3[] = $row->grantotal; } $om = 1; while ($maxval / $om > 100) { $om = $om * 10; } $bar_1 = new bar(75, '#0053A4'); $bar_2 = new bar(75, '#9933CC'); $bar_3 = new bar(75, '#639F45'); $bar_1->key('Contado', 10); $bar_2->key('Credito', 10); $bar_3->key('Total', 10); for ($i = 0; $i < count($data_1); $i++) { $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.'))); $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.'))); $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.'))); $bar_1->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]); $bar_2->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]); $bar_3->links[] = site_url("/ventas/vendedoresmensuales/index/{$anio}/" . $vendedor[$i]); } $g = new graph(); $g->title('Los 10 vendedores con los indice de ventas más altos en el año' . $anio, '{font-size: 22px; color:##00264A}'); $g->set_is_decimal_separator_comma(1); $g->data_sets[] = $bar_1; $g->data_sets[] = $bar_2; $g->data_sets[] = $bar_3; $g->set_x_labels($nombre); $g->set_x_label_style(10, '#000000', 3, 1); $g->set_x_axis_steps(10); $g->set_x_legend('Vendedores', 14, '#004381'); $g->bg_colour = '#FFFFFF'; $g->set_tool_tip('#key#<br>Vendedor: #x_label# <br>Monto: #tip#'); $g->set_y_max(ceil($maxval / $om)); $g->y_label_steps(5); $g->set_y_legend('Ventas x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381'); echo utf8_encode($g->render()); }
foreach ($questionorder as $i => $val) { if ($count1[$i]) { $stdev1[$i] = sqrt((double) $stdev1[$i] / (double) $count1[$i]); } if ($count2[$i]) { $stdev2[$i] = sqrt((double) $stdev2[$i] / (double) $count2[$i]); } $buckets1[$i] = $buckets1[$i] - 1; // Hack because there should not be ANY 0 values in the data. $buckets2[$i] = $buckets2[$i] - 1; $studbuckets1[$i] = $studbuckets1[$i] - 1; $studbuckets2[$i] = $studbuckets2[$i] - 1; } $maxbuckets1 = max($buckets1); $maxbuckets2 = max($buckets2); $graph = new graph($SURVEY_GWIDTH, $SURVEY_GHEIGHT); $graph->parameter['title'] = "{$question->text}"; $graph->x_data = $names; $graph->y_data['answers1'] = $buckets1; $graph->y_format['answers1'] = array('colour' => 'ltblue', 'line' => 'line', 'point' => 'square', 'shadow_offset' => 0.1, 'legend' => $stractualclass); $graph->y_data['answers2'] = $buckets2; $graph->y_format['answers2'] = array('colour' => 'ltorange', 'line' => 'line', 'point' => 'square', 'shadow_offset' => 0.1, 'legend' => $strpreferredclass); $graph->y_data['studanswers1'] = $studbuckets1; $graph->y_format['studanswers1'] = array('colour' => 'blue', 'line' => 'line', 'point' => 'square', 'shadow_offset' => 4, 'legend' => $stractualstudent); $graph->y_data['studanswers2'] = $studbuckets2; $graph->y_format['studanswers2'] = array('colour' => 'orange', 'line' => 'line', 'point' => 'square', 'shadow_offset' => 4, 'legend' => $strpreferredstudent); $graph->y_data['stdev1'] = $stdev1; $graph->y_format['stdev1'] = array('colour' => 'ltltblue', 'bar' => 'fill', 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.3); $graph->y_data['stdev2'] = $stdev2; $graph->y_format['stdev2'] = array('colour' => 'ltltorange', 'bar' => 'fill', 'shadow_offset' => 0.1, 'legend' => 'none', 'bar_size' => 0.2); $graph->offset_relation['stdev1'] = 'answers1';
$group = $groups[$groupid]; if (!($groupusers = get_users_by_capability($modcontext, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', $group->id, '', false))) { print_error('nostudentsingroup'); } else { $groupusers = array_keys($groupusers); } } else { print_error('errorinvalidgroup', 'group', null, $groupid); } } else { $groups = false; $group = false; $groupusers = array(); } require_capability('mod/quiz:viewreports', $modcontext); $line = new graph(800, 600); $line->parameter['title'] = ''; $line->parameter['y_label_left'] = get_string('participants'); $line->parameter['x_label'] = get_string('grade'); $line->parameter['y_label_angle'] = 90; $line->parameter['x_label_angle'] = 0; $line->parameter['x_axis_angle'] = 60; //following two lines seem to silence notice warnings from graphlib.php $line->y_tick_labels = null; $line->offset_relation = null; $line->parameter['bar_size'] = 1; // will make size > 1 to get overlap effect when showing groups $line->parameter['bar_spacing'] = 10; // don't forget to increase spacing so that graph doesn't become one big block of colour //pick a sensible number of bands depending on quiz maximum grade. $bands = $quiz->grade;
$total = $_GET ['total']; $_nomes = array (); $_quantidade = array (); for($i = 0; $i < $total; $i ++) { if (( int ) $_GET ['quantidade' . $i] > 0) { $_nomes [$i] = $_GET ['nome' . $i]; $_quantidade [$i] = ( int ) $_GET ['quantidade' . $i]; } } require 'library/open-flash-chart.php'; $g = new graph ( ); // // PIE chart, 60% alpha // $g->pie ( 60, '#FFFFFF' ); $g->bg_colour = '#FFFFFF'; // // pass in two arrays, one of data, the other data labels // $g->pie_values ( $_quantidade, $_nomes ); // // Colours for each slice, in this case some of the colours // will be re-used (3 colurs for 5 slices means the last two // slices will have colours colour[0] and colour[1]): //
function _epi_report() { // // main API to reports // if (func_num_args() > 0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } // always check dependencies if ($exitinfo = $this->missing_dependencies('vaccine')) { return print $exitinfo; } print "<span class='patient'>" . FTITLE_EPI_REPORTS . "</span><br/><br/>"; $n = new epi_report(); $g = new graph(); $n->report_menu($menu_id, $post_vars, $get_vars); print "<table><tr><td>"; // column 1 switch ($get_vars["report_menu"]) { case "TCL": $n->form_inclusive_dates($menu_id, $post_vars, $get_vars); if ($post_vars["submitreport"]) { $n->process_inclusive_dates($menu_id, $post_vars, $get_vars); } $n->display_tcl_inclusive_dates($menu_id, $post_vars, $get_vars); break; case "SUMMARY": $n->form_inclusive_dates($menu_id, $post_vars, $get_vars); if ($post_vars["submitreport"]) { $n->generate_summary($menu_id, $post_vars, $get_vars); } break; case "GRAPHS": $g->graph_menu($menu_id, $post_vars, $get_vars); switch ($get_vars["graph"]) { case "LINE": $get_vars["module"] = $this->module; $g->graph_line($menu_id, $post_vars, $get_vars); break; case "BAR": $get_vars["module"] = $this->module; $g->graph_bar($menu_id, $post_vars, $get_vars); break; case "PIE": $get_vars["module"] = $this->module; $g->graph_pie($menu_id, $post_vars, $get_vars); break; } break; } print "</td></tr></table>"; }
function print_profit_and_loss_statement() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $compare = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $graphics = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = tr('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = tr('Period Y-1'); } $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalper = 0.0; $totalacc = 0.0; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) { $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } else { $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } if (!$per_balance && !$acc_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $totalper = $totalacc = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->Font(); $salesper += $classper; $salesacc += $classacc; $classper = $classacc = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $per_balance *= -1; $acc_balance *= -1; $totalper += $per_balance; $totalacc += $acc_balance; $classper += $per_balance; $classacc += $acc_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($per_balance, $dec)); $rep->TextCol(3, 4, number_format2($acc_balance, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateper = $salesper + $classper; $calculateacc = $salesacc + $classacc; $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateper, $dec)); $rep->TextCol(3, 4, number_format2($calculateacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateper); $pg->z[] = abs($calculateacc); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function PN_BlogStatisticsProcess($target) { global $blogid, $pluginURL, $defaultURL, $blog; if (doesHaveOwnership()) { include_once 'lib/open-flash-chart.php'; $grpStyle = $_GET['grpStyle']; $grpData = explode("|", $_GET['grpData']); $grpTotal = $_GET['grpTotal']; $grpYear = $_GET['grpYear']; $grpTypeName = $_GET['grpTypeName']; $grpLinkType = $_GET['grpLinkType']; $grpXLabelType = isset($_GET['grpXLabelType']) ? $_GET['grpXLabelType'] : 0; $grpLabel = explode("|", $_GET['grpLabel']); $grpSubTitle = array(); $grpLabelTemp = array(); if (!empty($_GET['grpData'])) { if ($grpTypeName == "category") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode($grpLabel[$i] == 0 ? _t('분류없음') : htmlspecialchars(UTF8::lessenAsEm(getCategoryNameById($blogid, $grpLabel[$i]), 15))); } } else { if ($grpTypeName == "hits" || $grpTypeName == "cmmax" || $grpTypeName == "tbmax" || $grpTypeName == "tagmax") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode(htmlspecialchars(UTF8::lessenAsEm(str_replace(",", "-", getEntryTitleById($blogid, $grpLabel[$i])), 25))); } } else { if ($grpTypeName == "commenter" || $grpTypeName == "tag") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15)); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 6, '')); } $grpLabel = $grpLabelTemp; } else { if ($grpTypeName == "time") { for ($i = 0; $i < count($grpLabel); $i++) { $grpSubTitle[] = rawurlencode($grpLabel[$i] . "시"); } } else { if ($grpTypeName == "refer") { for ($i = 0; $i < count($grpLabel); $i++) { $tmpHost = explode('.', $grpLabel[$i]); $tmpHostCnt = count($tmpHost) - 1; $tmpDomain = (strlen($tmpHost[$tmpHostCnt]) < 3 ? $tmpHost[$tmpHostCnt - 2] . '.' : '') . $tmpHost[$tmpHostCnt - 1] . '.' . $tmpHost[$tmpHostCnt]; $cutDomain = explode('.', $tmpDomain); $grpSubTitle[] = htmlspecialchars($grpLabel[$i]); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($cutDomain[0], 6, '')); } $grpLabel = $grpLabelTemp; } else { if ($grpTypeName == "referkey") { for ($i = 0; $i < count($grpLabel); $i++) { $tmpLabel = explode('(', $grpLabel[$i]); $grpSubTitle[] = htmlspecialchars(UTF8::lessenAsEm($grpLabel[$i], 15)); $grpLabelTemp[] = htmlspecialchars(UTF8::lessenAsEm($tmpLabel[0], 6, '')); } $grpLabel = $grpLabelTemp; } } } } } } $g = new graph(); $g->bg_colour = '#FFFFFF'; if ($grpStyle == "pie") { $grpClickLink = ""; $grpPercent = array(); $grpLink = array(); for ($i = 0; $i < count($grpData); $i++) { $grpPercent[] = round($grpData[$i] / $grpTotal * 100, 0); } if ($grpLinkType == "archiveYear") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/archive/" . substr($grpLabel[$i], 0, 4); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "archiveMonth" && $grpYear != "9999") { for ($i = 0; $i < count($grpLabel); $i++) { $cutMonth = str_replace("월", "", $grpLabel[$i]); $tmpMonth = strlen($cutMonth) == 1 ? "0" . $cutMonth : $cutMonth; $permalink = $defaultURL . "/archive/" . $grpYear . $tmpMonth; $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "category") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/category/" . getCategoryLabelById($blogid, $grpLabel[$i]); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "entry") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . ($blog['useSlogan'] ? "/entry/" . getEntrySloganById($blogid, $grpLabel[$i]) : "/" . $grpLabel[$i]); $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } else { if ($grpLinkType == "tag") { for ($i = 0; $i < count($grpLabel); $i++) { $permalink = $defaultURL . "/tag/" . $grpLabel[$i]; $grpLink[] = "javascript:window.open('{$permalink}');void(0)"; } $grpClickLink = "<br>click on the pie."; } } } } } $g->pie(75, '#ffffff', '#000000', false, 1); $g->pie_values($grpData, $grpLabel, $grpLink, $grpSubTitle); $g->pie_slice_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D')); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#(#percent#%25)' . $grpClickLink); } else { if ($grpStyle == "bar") { $g->title(' ', '{font-size:12px; color:#000000;margin-top:0px;padding:3px;}'); $g->set_data($grpData); $g->set_bar_titles($grpSubTitle); $g->bar_glass(70, '#68B1D9', '#62A0C1', '', 12); $g->bar_colours(array('#B9D2E6', '#E2B11C', '#A3CF22', '#EC7122', '#4FC0C0', '#D45E5E', '#A275A2', '#52A7D2', '#9F373B', '#B4ADA5', '#5FC97E', '#CFB85D', '#9DC64E', '#FFAB29', '#E23838', '#43CEA9', '#4CA9D9', '#BA4ECA', '#6C79DA', '#CCCCCC', '#AB5C06', '#C06868', '#5FC97E', 'CFB85D')); $g->x_axis_colour('#909090', '#D2D2FB'); $g->y_axis_colour('#909090', '#D2D2FB'); $g->set_x_labels($grpLabel); $g->set_x_label_style(10, '#000000', $grpXLabelType, -1); $g->set_y_label_style(9, '#888888'); $tmp_data_max = floor(Max($grpData) * 1.2); if ($tmp_y_max = $tmp_data_max % 10) { $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max); } $g->set_y_max($tmp_data_max); $g->set_y_legend('', 11, '#736AFF'); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#'); } else { if ($grpStyle == "line") { $g->title('', '{font-size:1px; color:#000000;}'); $g->set_data($grpData); $g->line_dot(2, 4, '#6FBBC6', _t('최근 7일간 방문자 수'), 11); // <-- 3px thick + dots $g->set_x_labels($grpLabel); $g->set_x_label_style(8, '#333333', $grpXLabelType, -1); $g->x_axis_colour('#909090', '#e7e7e7'); $g->y_axis_colour('#909090', '#e7e7e7'); $tmp_data_max = floor(Max($grpData) * 1.2); if ($tmp_y_max = $tmp_data_max % 10) { $tmp_data_max = $tmp_data_max + (10 - $tmp_y_max); } $g->set_y_max($tmp_data_max); $g->set_y_legend('', 1, '#736AFF'); $g->y_label_steps(4); $g->set_y_label_style(8, '#333333', $grpXLabelType, -1); $g->set_tool_tip((count($grpSubTitle) ? '#x_title#<br>' : '#x_label#<br>') . '#val#'); } } } echo $g->render(); flush(); } } }
} $dayfinish = $daystart + 86400; $hours = array(); for ($i = 0; $i <= 23; $i++) { $logs[$i] = 0; $hour = $daystart + $i * 3600; $hours[$i] = $i; } $rawlogs = report_log_userday($user->id, $courseselect, $daystart, $logreader); if (empty($rawlogs)) { return; } foreach ($rawlogs as $rawlog) { $logs[$rawlog->hour] = $rawlog->num; } $graph = new graph(750, 400); $a = new stdClass(); $a->coursename = format_string($course->shortname, true, array('context' => $coursecontext)); $a->username = fullname($user, true); $graph->parameter['title'] = get_string("hitsoncoursetoday", "", $a); $graph->x_data = $hours; $graph->y_data['logs'] = $logs; $graph->y_order = array('logs'); if (!empty($CFG->preferlinegraphs)) { $graph->y_format['logs'] = array('colour' => 'blue', 'line' => 'line'); } else { $graph->y_format['logs'] = array('colour' => 'blue', 'bar' => 'fill', 'bar_size' => 0.9); } $graph->parameter['y_label_left'] = get_string("hits"); $graph->parameter['label_size'] = "12"; $graph->parameter['x_axis_angle'] = 0;
function grafico($anio = '') { $this->load->library('Graph'); $this->lang->load('calendar'); if (empty($anio)) { return; } $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $mSQL = "SELECT MONTHNAME(fecha)AS mes,\n\t\tAVG(sueldoa) AS anterior,\n\t\tAVG(sueldo) AS actual\n\t\tFROM ausu\n\t\tWHERE fecha>='{$fechai}' AND fecha<='{$fechaf}'\n\t\tGROUP BY mes ORDER BY fecha"; //echo $mSQL; $maxval = 0; $query = $this->db->query($mSQL); foreach ($query->result() as $row) { if ($row->anterior > $maxval) { $maxval = $row->anterior; } $nmes[] = $this->lang->line('cal_' . strtolower($row->mes)); $data_1[] = $row->anterior; $data_2[] = $row->actual; //$data_3[]=$row->actual; } $om = 1; while ($maxval / $om > 100) { $om = $om * 10; } $bar_1 = new bar(75, '#0053A4'); $bar_2 = new bar(75, '#9933CC'); $bar_3 = new bar(75, '#639F45'); $bar_1->key('Sueldo Anterior', 10); $bar_2->key('Sueldo con Aumento', 10); //$bar_3->key('Total' ,10); for ($i = 0; $i < count($data_1); $i++) { $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.'))); $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.'))); $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.'))); } $g = new graph(); $g->title('Promedio de Aumento de Sueldos en el año ' . $anio, '{font-size: 22px; color:##00264A}'); $g->set_is_decimal_separator_comma(1); $g->data_sets[] = $bar_1; $g->data_sets[] = $bar_2; $g->data_sets[] = $bar_3; $g->set_x_labels($nmes); $g->set_x_label_style(9, '#000000', 3, 1); $g->set_x_axis_steps(8); $g->set_x_legend('Meses ', 16, '#004381'); $g->bg_colour = '#FFFFFF'; $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#'); $g->set_y_max(ceil($maxval / $om)); $g->y_label_steps(5); $g->set_y_legend('Sueldo x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381'); echo utf8_encode($g->render()); }
} if (in_array($type, $dot_types)) { if (!is_file(_BASEPATH_ . '/tmp/admin/' . $type . $start_date . $end_date . '.png') || isset($_GET['refresh'])) { $query = "SELECT `value`,UNIX_TIMESTAMP(`time`) as `time` FROM `{$dbtable_prefix}stats_dot` WHERE `dataset`='{$type}'"; if (!empty($start_date)) { $query .= " AND `time`>='" . date('Ymd', $start_date) . "'"; } if (!$forced_end) { $query .= " AND `time`<='" . date('Ymd', $end_date) . "'"; } $query .= " ORDER BY `dot_id` ASC"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } if (mysql_num_rows($res)) { $graph = new graph(500, 200); $i = 0; $min_time = 0; $max_time = 0; $min_val = 0; $max_val = 0; while ($rsrow = mysql_fetch_assoc($res)) { if ($i == 0) { $min_time = $rsrow['time']; $min_val = $rsrow['value']; } if ($min_val > $rsrow['value']) { $min_val = $rsrow['value']; } if ($max_val < $rsrow['value']) { $max_val = $rsrow['value'];
function gdiarias($anio = '', $cliente = '', $mes = '') { $this->load->library('Graph'); if (empty($mes) or empty($anio) or empty($cliente)) { return; } $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $mSQL = "SELECT cod_cli,nombre,fecha,DAYOFMONTH(fecha) as dia, \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS grantotal, \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS contado, \n\t\tsum(gtotal*IF(tipo='D', -1, 1)) AS credito \n\t\tFROM fmay \n\t\tWHERE tipo<>'X' AND fecha>='{$fechai}' AND fecha<='{$fechaf}' AND cod_cli='{$cliente}' \n\t\tGROUP BY fecha ORDER BY fecha,grantotal DESC LIMIT 31"; //echo $mSQL; $maxval = 0; $query = $this->db->query($mSQL); foreach ($query->result() as $row) { if ($row->grantotal > $maxval) { $maxval = $row->grantotal; } $fecha[] = $row->dia; $data_1[] = $row->contado; $data_2[] = $row->credito; $data_3[] = $row->grantotal; } $nombre = $row->nombre; $om = 1; while ($maxval / $om > 100) { $om = $om * 10; } $bar_1 = new bar(75, '#0053A4'); $bar_2 = new bar(75, '#9933CC'); $bar_3 = new bar(75, '#639F45'); $bar_1->key('Contado', 10); $bar_2->key('Credito', 10); $bar_3->key('Total', 10); for ($i = 0; $i < count($data_1); $i++) { $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.'))); $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.'))); $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.'))); } $g = new graph(); $g->set_is_decimal_separator_comma(1); if ($maxval > 0) { $g->title('Compras de el cliente ' . $nombre . ' en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:#0F3054}'); $g->data_sets[] = $bar_1; $g->data_sets[] = $bar_2; $g->data_sets[] = $bar_3; $g->set_x_labels($fecha); $g->set_x_label_style(10, '#000000', 3, 1); $g->set_x_axis_steps(10); $g->set_x_legend('Dias', 14, '#004381'); $g->bg_colour = '#FFFFFF'; $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#'); $g->set_y_max(ceil($maxval / $om)); $g->y_label_steps(5); $g->set_y_legend('hospitalidad x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381'); } else { $g->title('No existen ventas con los datos seleccionados', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; echo utf8_encode($g->render()); }
function add_data_tip($data, $tip) { $this->data[] = $data; $this->tips[] = graph::esc($tip); }
function gdiarias($anio = '', $proveed = '', $mes = '') { $this->load->library('Graph'); if (empty($mes) or empty($anio) or empty($proveed)) { return; } $proveed = radecode($proveed); $fechai = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '31'; $dbfechai = $this->db->escape($fechai); $dbfechaf = $this->db->escape($fechaf); $dbproveed = $this->db->escape($proveed); $mSQL = "SELECT LEFT(nombre,10)as nombre,proveed,DAYOFMONTH(fecha) AS dia ,\n\t\tSUM(montonet*IF(tipo_doc='NC', -1, 1)) AS grantotal,\n\t\tSUM(credito*IF( tipo_doc='NC', -1, 1)) AS credito,\n\t\tSUM(inicial*IF( tipo_doc='NC', -1, 1)) AS contado\n\t\tFROM scst\n\t\tWHERE tipo_doc<>'NE' AND fecha>={$dbfechai} AND fecha<={$dbfechaf} AND proveed={$dbproveed}\n\t\t\tAND actuali >= fecha\n\t\tGROUP BY fecha ORDER BY fecha,grantotal DESC LIMIT 31"; //echo $mSQL; $maxval = 0; $query = $this->db->query($mSQL); foreach ($query->result() as $row) { if ($row->grantotal > $maxval) { $maxval = $row->grantotal; } $fecha[] = $row->dia; $nombre = str_replace('&', '', $row->nombre); //$data_1[]=$row->contado; //$data_2[]=$row->credito; $data_3[] = $row->grantotal; } $om = 1; while ($maxval / $om > 100) { $om = $om * 10; } //$bar_1 = new bar(75, '#0053A4'); //$bar_2 = new bar(75, '#9933CC'); $bar_3 = new bar(75, '#639F45'); //$bar_1->key('Contado',10); //$bar_2->key('Credito',10); $bar_3->key('Total Bs.', 10); for ($i = 0; $i < count($data_3); $i++) { //$bar_1->add_data_tip($data_1[$i]/$om, graph::esc( number_format($data_1[$i],2,',','.'))); //$bar_2->add_data_tip($data_2[$i]/$om, graph::esc( number_format($data_2[$i],2,',','.'))); $bar_3->add_data_tip($data_3[$i] / $om, graph::esc(number_format($data_3[$i], 2, ',', '.'))); } $g = new graph(); $g->set_is_decimal_separator_comma(1); if ($maxval > 0) { $g->title('Compras a ' . $nombre . ' en el mes ' . $mes . '/' . $anio, '{font-size: 16px; color:##00264A}'); //$g->data_sets[] = $bar_1; //$g->data_sets[] = $bar_2; $g->data_sets[] = $bar_3; $g->set_x_labels($fecha); $g->set_x_label_style(10, '#000000', 3, 1); $g->set_x_axis_steps(10); $g->set_x_legend('Dias', 14, '#004381'); $g->bg_colour = '#FFFFFF'; $g->set_tool_tip('#key#<br>Dia: #x_label# <br>Monto: #tip#'); $g->set_y_max(ceil($maxval / $om)); $g->y_label_steps(5); $g->set_y_legend('Compras x ' . number_format($om, 0, '', '.') . ' (Bs)', 16, '#004381'); } else { $g->title('No existen compras con los datos seleccionados', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; echo utf8_encode($g->render()); }
function metric_as_graph($result, $xaxis, $metric, $system, $start_date, $end_date) { set_time_limit(900); $myresult = $result; $nrows = 0; $xmax = 0; while ($myresult->fetchInto($row)) { $keys = array_keys($row); foreach ($keys as $key) { $rawdata[$nrows][$key] = $row[$key]; } $nrows++; } if ($xaxis == 'nproc') { for ($i = 0; $i <= nprocs($system); $i++) { $x[$i] = ""; $y[$i] = ""; $min[$i] = ""; $max[$i] = ""; $stddev[$i] = ""; $max[$i] = ""; $ysigma[2 * $i] = ""; $ysigma[2 * $i + 1] = ""; } } if ($metric == 'jobcount') { for ($i = 0; $i < $nrows; $i++) { $x[$i] = $rawdata[$i][0]; if ($xaxis == 'nproc') { if ($x[$i] > $xmax) { $xmax = $x[$i]; } $y[$x[$i]] = $rawdata[$i][1]; } else { $y[$i] = $rawdata[$i][1]; } } } elseif ($metric == 'cpuhours' || $metric == 'xfactor' || $metric == 'users' || $metric == 'groups') { for ($i = 0; $i < $nrows; $i++) { $x[$i] = $rawdata[$i][0]; if ($xaxis == 'nproc') { if ($x[$i] > $xmax) { $xmax = $x[$i]; } $y[$x[$i]] = $rawdata[$i][2]; } else { $y[$i] = $rawdata[$i][2]; } } } elseif ($metric == 'backlog') { for ($i = 0; $i < $nrows; $i++) { $x[$i] = $rawdata[$i][0]; if ($xaxis == 'nproc') { if ($x[$i] > $xmax) { $xmax = $x[$i]; } $y[$x[$i]] = time_to_hrs($rawdata[$i][3]); $max[$x[$i]] = time_to_hrs($rawdata[$i][2]); } else { $y[$i] = time_to_hrs($rawdata[$i][3]); $max[$i] = time_to_hrs($rawdata[$i][2]); } } } else { for ($i = 0; $i < $nrows; $i++) { $x[$i] = $rawdata[$i][0]; if ($xaxis == 'nproc') { if ($x[$i] > $xmax) { $xmax = $x[$i]; } $y[$x[$i]] = $rawdata[$i][4]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $y[$x[$i]])) { $y[$x[$i]] = time_to_hrs($y[$x[$i]]); } $min[$x[$i]] = $rawdata[$i][2]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $min[$x[$i]])) { $min[$x[$i]] = time_to_hrs($min[$x[$i]]); } $max[$x[$i]] = $rawdata[$i][3]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $max[$x[$i]])) { $max[$x[$i]] = time_to_hrs($max[$x[$i]]); } $stddev[$x[$i]] = $rawdata[$i][5]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $stddev[$x[$i]])) { $stddev[$x[$i]] = time_to_hrs($stddev[$x[$i]]); } $ysigma[2 * $x[$i]] = $y[$x[$i]] - $stddev[$x[$i]]; if ($ysigma[2 * $x[$i]] < 0.0) { $ysigma[2 * $x[$i]] = 0.0; } $ysigma[2 * $x[$i] + 1] = $y[$x[$i]] + $stddev[$x[$i]]; } else { $y[$i] = $rawdata[$i][4]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $y[$i])) { $y[$i] = time_to_hrs($y[$i]); } $min[$i] = $rawdata[$i][2]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $min[$i])) { $min[$i] = time_to_hrs($min[$i]); } $max[$i] = $rawdata[$i][3]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $max[$i])) { $max[$i] = time_to_hrs($max[$i]); } $stddev[$i] = $rawdata[$i][5]; if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $stddev[$i])) { $stddev[$i] = time_to_hrs($stddev[$i]); } $ysigma[2 * $i] = $y[$i] - $stddev[$i]; if ($ysigma[2 * $i] < 0.0) { $ysigma[2 * $i] = 0.0; } $ysigma[2 * $i + 1] = $y[$i] + $stddev[$i]; } } } $cache = APACHE_CACHE_DIR; if (!file_exists("/tmp/" . $cache)) { mkdir("/tmp/" . $cache, 0750); } $plot = $system . "-" . $metric . "_vs_" . $xaxis . "-" . $start_date . "-" . $end_date . ".png"; // $graph = new graph(640,480,$plot,2,0); $graph = new graph(800, 600, $plot, 2, 0); $graph->img->SetMargin(75, 30, 30, 75); if ($xaxis == 'nproc') { $graph->SetScale("linlin"); //$graph->xaxis->SetAutoMax(nprocs($system)); } else { $graph->SetScale("textlin"); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetTickLabels($x); } $graph->xaxis->title->Set($xaxis); $graph->yaxis->title->Set($metric . units($metric)); if ($metric == "walltime_acc" || $metric == "cpu_eff") { $graph->yscale->SetAutoMax(1.1); } elseif ($metric == "xfactor") { $graph->yscale->SetAutoMin(1.0); } if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") { $maxbar = new BarPlot($max); $maxbar->SetWidth(1.0); $maxbar->SetFillColor("gray"); $maxbar->SetLegend("Maximum"); $graph->Add($maxbar); } else { if ($metric == "backlog") { $maxbar = new BarPlot($max); $maxbar->SetWidth(1.0); $maxbar->SetFillColor("gray"); $maxbar->SetLegend("CPU Hours"); $graph->Add($maxbar); } } $ybar = new BarPlot($y); $ybar->SetWidth(1.0); if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") { $ybar->SetLegend("Mean"); } else { if ($metric == "backlog") { $ybar->SetLegend("Queue Hours"); } } $graph->Add($ybar); if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") { $minbar = new BarPlot($min); $minbar->SetWidth(1.0); $minbar->SetFillColor("white"); $minbar->SetLegend("Minimum"); $graph->Add($minbar); $errbars = new ErrorPlot($ysigma); $errbars->SetColor("red"); //$errbars->SetCenter(); $errbars->SetWeight(2); $errbars->SetLegend("Std.Dev."); $graph->Add($errbars); } $graph->Stroke(); $imgurl = $cache . rawurlencode($plot); echo "<img src=\"" . $imgurl . "\">\n"; }
} $avgSatffTime = floor($avgSatffTime); // echo '<br>stf : '.$staffid. 'avg '. $avgSatffTime; } //if ends $arrDataAuto[$count][0] = $stf_value; $arrDataAuto[$count][1] = $avgSatffTime; $count++; } ?> <tr> <td colspan="2"> <?php $staffperfomance_auto = TEXT_REPORTS_STAFF_SUMMARY_AUTO; $graphObj3 = new graph(8, 900, 350); $graphObj3->setChartParams($staffperfomance_auto, 1, 1, 0); $graphObj3->addChartData($arrDataAuto); $graphObj3->renderChart(); ?> </td> </tr> <tr><td colspan="2" align="center"> <div class="pagination_links"> <?php $st = 0; $end = $limitst; $pageCount = 0; $totalStaff = getStaffCount(); if ($totalStaff > 0) { do {
function grafico($anio = '') { if (empty($anio)) { return; } $this->load->library('Graph'); $titulo = $data_1 = $data_2 = $data_3 = $data_tips_1 = $data_tips_2 = $data_tips_3 = array(); $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $data = $this->_sincrodata($fechai, $fechaf); $om = 1; while ($this->maxval / $om > 100) { $om = $om * 10; } //print_r($data); foreach ($data as $row) { $titulo[] = $row['mes']; $data_1[] = $row['contado'] / $om; $data_2[] = $row['credito'] / $om; $data_3[] = $row['cobrado'] / $om; $data_tips_1[] = graph::esc(number_format($row['contado'], 2, ',', '.')); $data_tips_2[] = graph::esc(number_format($row['credito'], 2, ',', '.')); $data_tips_3[] = graph::esc(number_format($row['cobrado'], 2, ',', '.')); } $odata_1 = new bar_fade(50, '0xCC3399'); $odata_1->key('Contado', 10); $odata_1->data = $data_1; $odata_1->tips = $data_tips_1; $odata_2 = new bar_fade(50, '0x80a033'); $odata_2->key('Crédito', 10); $odata_2->data = $data_2; $odata_2->tips = $data_tips_2; $odata_4 = new line_hollow(2, 3, '0x9933CC'); $odata_4->key('Cobranzas a Crédito', 10); $odata_4->data = $data_3; $odata_4->tips = $data_tips_3; for ($i = 0; $i < count($data_1); $i++) { $mes = $i + 1; $odata_1->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); $odata_2->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); $odata_3->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); } $g = new Graph(); $g->set_is_decimal_separator_comma(1); if ($this->maxval > 0) { $g->title('Ventas en el año ' . $anio, '{font-size:18px; color: #d01f3c}'); $g->data_sets[] = $odata_1; $g->data_sets[] = $odata_2; $g->data_sets[] = $odata_4; $g->set_y_max(ceil($this->maxval / $om)); $g->y_label_steps(5); $g->set_x_labels($titulo); $ejey = number_format($om, 0, '', ' '); $g->set_y_legend('Venta X ' . $ejey . ' (Bs)', 14, '0x639F45'); $g->set_x_legend('Meses', 14, '0x639F45'); $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#'); } else { $g->title('NO existen ventas en el año seleccionado', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; echo utf8_encode($g->render()); }
echo number_format($replytimeCountVal / $replyCountVal); } ?> </td> </tr> <tr> <td colspan="2"> <?php $count = 0; foreach ($dataArray as $key => $value) { $arrData[$count][0] = $key; $arrData[$count][1] = $value; $count++; } //print_r($arrData); $graphObj3 = new graph(8); $graphObj3->setChartParams("Ticket Statistics", 1, 1, 0); $graphObj3->addChartData($arrData); $graphObj3->renderChart(); ?> </td> </tr> <?php } else { ?> <tr><td colspan="2" align="center"><?php echo TEXT_NO_RECORDS; ?> </td></tr> <?php
function grafico($mes = NULL, $anio = NULL) { if (empty($mes) and empty($anio)) { return; } $this->load->library('Graph'); $titulo = $data_1 = $data_2 = $data_3 = $data_tips_1 = $data_tips_2 = $data_tips_3 = array(); $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $data = $this->_sincrodata($fechai, $fechaf); $om = 1; while ($this->maxval / $om > 100) { $om = $om * 10; } foreach ($data as $row) { $titulo[] = $row['dia']; $data_1[] = $row['contado'] / $om; $data_2[] = $row['credito'] / $om; $data_3[] = $row['cobrado'] / $om; $data_tips_1[] = graph::esc(number_format($row['contado'], 2, ',', '.')); $data_tips_2[] = graph::esc(number_format($row['credito'], 2, ',', '.')); $data_tips_3[] = graph::esc(number_format($row['cobrado'], 2, ',', '.')); } $odata_1 = new bar_fade(50, '0xCC3399'); $odata_1->key('Contado', 10); $odata_1->data = $data_1; $odata_1->tips = $data_tips_1; $odata_2 = new bar_fade(50, '0x80a033'); $odata_2->key('Crédito', 10); $odata_2->data = $data_2; $odata_2->tips = $data_tips_2; $odata_3 = new line_hollow(2, 3, '0x9933CC'); $odata_3->key('Cobranzas a Crédito', 10); $odata_3->data = $data_3; $odata_3->tips = $data_tips_3; $g = new Graph(); if ($this->maxval > 0) { $g->title('Ventas del mes ' . $mes . '/' . $anio, '{font-size:18px; color: #d01f3c}'); $g->set_is_decimal_separator_comma(1); $g->data_sets[] = $odata_3; $g->data_sets[] = $odata_1; $g->data_sets[] = $odata_2; $g->set_y_max(ceil($this->maxval / $om)); $g->y_label_steps(5); $g->set_x_labels($titulo); $ejey = number_format($om, 0, '', '.'); $g->set_y_legend('Venta X ' . $ejey . ' (Bs)', 14, '0x639F45'); $g->set_x_legend('Días del mes ' . $mes, 14, '0x639F45'); $g->set_tool_tip('#key#<br>Día: #x_label# <br>Monto: #tip#'); } else { $g->title('No existen ventas en la Fecha Seleccionada', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; //$g->set_bg_image(site_url('/images/ventafon.png'), 'center', 'middle' ); echo utf8_encode($g->render()); }
function graph_line() { // // main submodule for line graph definitions // // calls form_graph_line() // display_graph_line() // process_graph_line() // // always check dependencies if ($exitinfo = $this->missing_dependencies('graph')) { return print($exitinfo); } if (func_num_args()>0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } $g = new graph; print "<table width='600'><tr valign='top'><td>"; // column 1 if ($post_vars["submitgraph"]) { $g->process_linegraph($menu_id, $post_vars, $get_vars); } if ($get_vars["view_id"]) { $g->draw_linegraph($menu_id, $post_vars, $get_vars); } else { $g->form_linegraph($menu_id, $post_vars, $get_vars); } print "</td><td>"; // column 2 $g->display_linegraph($menu_id, $post_vars, $get_vars); print "</td></tr></table>"; }
$max_value = 0; while( $row = $db->fetch_assoc($query) ){ $data_1[] = $row['vr_totalvenda']; $data_2[] = $row['vr_custo']; $data_3[] = $row['vr_totalvenda']-$row['vr_custo']; $labels[] = date('d/m/Y',strtotime($row['data_venda'])); $max_value = ($max_value<$row['vr_totalvenda'])?$row['vr_totalvenda']:$max_value; } $g = new graph(); $g->set_data( $data_1 ); $g->set_data( $data_2 ); $g->set_data( $data_3 ); $g->line_hollow( 3, 5, '0x9933CC', 'Venda', 10 ); $g->line_hollow( 3, 5, '0xCC3399', 'Custo', 10); // <-- 3px thick + dots $g->line_hollow( 3, 5, '0x80a033', 'Lucro', 10 ); $g->set_x_labels( $labels ); $g->set_x_label_style( 10, '0x000000', 0, 2 ); $g->set_y_max( $max_value ); $g->y_label_steps( 4 ); $g->set_y_legend( 'Valores em Real - R$', 12, '#000000' );
/** * action_admin_return_ofc_hitrates() * * the function returns dynamic data (hitrate of apc) and visualizes an piechart with ofc. * function consists of 4 segments: * (1) get data * (2) init ofc * (3) draw the chart * (4) render it * * @return dynamic data for an open flash chart */ public function action_admin_return_ofc_hitrates() { /** * (1) get DATA for Visualization */ // get apc cache $cache_apc = Clansuite_Cache_Factory::getCache('apc'); $apc_stats = $cache_apc->stats(); // debug display of the stats data // var_dump($apc_stats); // setup the data array $data = array(); $data[] = $apc_stats['cache_info']['num_hits']; $data[] = $apc_stats['cache_info']['num_misses']; /** * (2) initialize Open Flash Chart */ include 'libraries/open-flash-chart/php-ofc-library/open-flash-chart.php'; $g = new graph(); /** * (3) draw the ofc chart */ // title $g->title('APC Hitrate', '{font-size:18px; color: #d01f3c}'); // ok, now draw one piece of the pie :) $g->pie(60, '#505050', '{font-size: 11px; color: #404040;'); /** * we have to pass in 2 arrays * (1) $data * (2) labels for the data */ $g->pie_values($data, array('Hits', 'Misses')); // colours for each slice (hits = green, misses = red) $g->pie_slice_colours(array('#acb132', '#d01f3c')); // mouseover tooltip displayes the values $g->set_tool_tip('#val#'); /** * (4) output/generate the dynamic data for the swf */ echo $g->render(); // eject here unnicely, because of headers exist error // @todo debug and find out, where after $g->render any output is done exit; }
ORDER BY grptime DESC'; $userspermin = get_recordset_sql($sql); //print_r($userspermin); $permincount = array(); $maxpermin = 1; $xcount = 1; while ($row = rs_fetch_next_record($userspermin)) { $permincount[] = $row->permin; $xdata[$xcount] = $xcount++; if ($maxpermin < $row->permin) { $maxpermin = $row->permin; } } //print_r($permincount); rs_close($userspermin); $bar = new graph(800, 600); $bar->parameter['title'] = ''; $bar->parameter['y_label_left'] = 'users per minute'; $bar->parameter['x_label'] = 'count'; $bar->parameter['y_label_angle'] = 90; $bar->parameter['x_label_angle'] = 0; $bar->parameter['x_axis_angle'] = 60; //following two lines seem to silence notice warnings from graphlib.php $bar->y_tick_labels = null; $bar->offset_relation = null; //$bar->parameter['bar_size'] = 1; // will make size > 1 to get overlap effect when showing groups //$bar->parameter['bar_spacing'] = 1; // don't forget to increase spacing so that graph doesn't become one big block of colour $bar->x_data = $xdata; $bar->y_data['count'] = $permincount; $bar->y_format['count'] = array('colour' => 'blue', 'bar' => 'fill'); $bar->y_order = array('count');