function return_ofc_24() { global $cms, $ps; $styles =& $cms->theme->styles; $hours = array(); $labels = array(); $data = array(); $data_avg = array(); $conns = array(); $conns_avg = array(); $sum = 0; $avg = 0; $maxlimit = 100; $maxlimit2 = 100; $minlimit = 0; $max = 24; list($newest) = $ps->db->fetch_list("SELECT hour FROM {$ps->t_map_hourly} ORDER BY statdate DESC,hour DESC LIMIT 1"); if ($newest === null) { $newest = date("H"); } // build a list of hours in the proper order for ($h = $newest; count($hours) < 24; $h--) { if ($h < 0) { $h = 23; } $hours[sprintf('%02d:00', $h)] = 'null'; } $hours = array_reverse($hours); // get the last 24 hours of data $ps->db->query("SELECT statdate,hour,SUM(kills),SUM(connections) " . "FROM {$ps->t_map_hourly} " . "GROUP BY statdate,hour " . "ORDER BY statdate DESC,hour DESC LIMIT {$max}"); // build our data and labels $data = $hours; $conns = $hours; $maxdata = 0; $maxconn = 0; while (list($statdate, $hour, $kills, $connections) = $ps->db->fetch_row(0)) { $hh = sprintf('%02d:00', $hour); $sum += $kills; $data[$hh] = $kills; $conns[$hh] = $connections; $maxdata = max($maxdata, $kills); $maxconn = max($maxconn, $connections); } $labels = array_keys($hours); # print_r($hours); # print_r($data); # print_r($conns); # print_r($labels); if ($data) { $avg = $sum / count($data); $data_avg = array_pad(array(), count($data), $avg); # $maxlimit = ceil(ceil($maxdata / 100) * 100); } if ($conns) { $avg = $sum / count($conns); $conns_avg = array_pad(array(), count($conns), $avg); # $maxlimit2 = ceil(ceil($maxconn / 100) * 100); } include_once PS_ROOTDIR . '/includes/ofc/open-flash-chart.php'; $g = new graph(); $g->bg_colour = $styles->val('flash.last24.bgcolor', 'flash.bgcolor'); $g->title($styles->val('flash.last24.title', $cms->trans('Last 24 Hours'), true), '{' . $styles->val('flash.last24.title.style', 'font-size: 16px', true) . '}'); $g->set_data($data_avg); $g->set_data($data); // $g->set_data($conns_avg); $g->set_data($conns); $g->attach_to_y_right_axis(3); $lines = $styles->attr('flash.last24.lines.line'); $g->line(coalesce($lines[0]['width'], 1), coalesce($lines[0]['color'], '#9999ee'), coalesce($lines[0]['key'], $cms->trans('Average Kills')), coalesce($lines[0]['key_size'], $styles->val('flash.last24.lines.key_size'), 9)); $g->line_dot(coalesce($lines[1]['width'], 2), coalesce($lines[1]['dot_size'], 5), coalesce($lines[1]['color'], '#5555ff'), coalesce($lines[1]['key'], $cms->trans('Kills')), coalesce($lines[1]['key_size'], $styles->val('flash.last24.lines.key_size'), 9)); $g->line_dot(coalesce($lines[2]['width'], 1), coalesce($lines[2]['dot_size'], 3), coalesce($lines[2]['color'], '#000000'), coalesce($lines[2]['key'], $cms->trans('Connections')), coalesce($lines[2]['key_size'], $styles->val('flash.last24.lines.key_size'), 9)); // label each point with its value $g->set_x_labels($labels); // $g->set_x_axis_steps(count($labels) / 3 + 1); // $g->set_x_tick_size(1); $g->set_x_label_style(10, '#000000', 0, 3, '#cccccc'); // $g->set_x_label_style( 10, '0x000000', 0, 2 ); // $g->set_x_label_style('none'); # $g->set_x_label_style( 8, '#000000', 2 ); $g->set_inner_background(coalesce($styles->val('flash.last24.bg_inner1', 'flash.bg_inner1'), '#E3F0FD'), coalesce($styles->val('flash.last24.bg_inner2', 'flash.bg_inner2'), '#CBD7E6'), coalesce($styles->val('flash.last24.bg_inner_angle', 'flash.bg_inner_angle'), 90)); $g->x_axis_colour('#eeeeee', '#eeeeee'); $g->y_axis_colour('#5555ff', '#eeeeee'); $g->y_right_axis_colour('#000000', '#eeeeee'); // $g->set_x_offset( false ); // set the Y max $g->set_y_max($maxdata); $g->set_y_min(0); $g->set_y_right_max($maxconn); $g->set_y_right_min(0); /* $g->set_y_max($maxlimit); $g->set_y_min($minlimit); $g->set_y_right_min($minlimit); $g->set_y_right_max($maxlimit2); */ $g->set_y_legend(coalesce($lines[1]['key'], $cms->trans('Kills')), 12, coalesce($lines[1]['color'], '#5555ff')); $g->set_y_right_legend(coalesce($lines[2]['key'], $cms->trans('Connections')), 12, coalesce($lines[2]['color'], '#000000')); // $g->y_label_steps(); $g->set_tool_tip($styles->val('flash.last24.tooltip', '#key#<br>#val# (#x_label#)', true)); // label every 20 (0,20,40,60) // $g->x_label_steps( 2 ); // display the data print $g->render(); }
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(); } } }
/** */ function chart_flash($data, $params) { if (empty($data)) { return; } include_once YF_PATH . 'libs/yf_open_flash_chart/open-flash-chart.php'; $width = isset($params['width']) ? $params['width'] : '90%'; $height = isset($params['height']) ? $params['height'] : '90%'; $g = new graph(); $g->js_path = isset($params['js_path']) ? $params['js_path'] : '/js/'; $g->swf_path = isset($params['swf_path']) ? $params['swf_path'] : '/js/'; $g->title(' ', '{font-size: 20px;}'); $g->bg_colour = '#e9e9e9'; $g->x_axis_colour('#000000', '#c1c1c1'); $g->y_axis_colour('#000000', '#c1c1c1'); $g->set_data($data); // Find maximal strlen of x axis label foreach ((array) $data as $k => $v) { $xlabel_len[] = _strlen($k); } if (max($xlabel_len) > 7) { $orientation = 2; } else { $orientation = 0; } $g->set_x_labels(array_keys($data)); $g->set_x_label_style(10, '#000000', $orientation, 2); $g->set_y_max(max($data)); $g->set_y_label_style(10, '#000000', 0, 2); $g->set_y_legend('Price', 10, '#000000'); $g->set_x_legend('Date', 10, '#000000'); $g->set_tool_tip('#val# EUR on #x_label#'); $g->line_dot(2, 3, '#0750D9', '', 10); // формат значений $g->set_num_decimals(0); $g->set_y_format('#val#€'); $g->set_width($width); $g->set_height($height); $g->set_output_type('js'); return $g->render(); }
/** * Generates report of projects created * * @access public * @param nil * @return void */ function projectsCreated() { //Load Language File For this $this->lang->load('enduser/reports', $this->config->item('language_code')); //Load Library File $this->load->library('graph'); // generate some random data srand((double) microtime() * 1000000); // NOTE: how we are filling 3 arrays full of data, // one for each line on the graph $data_1 = array(); $mon = array(); for ($i = 0; $i < 6; $i++) { $lastmonth = mktime(0, 0, 0, date("m") - $i, date("d"), date("Y")); $month = date('n', $lastmonth); $year = date('Y', $lastmonth); $data_1[] = $this->skills_model->getNumProjectsByMonth($month, $year); $mon[] = date('M', $lastmonth); } $g = new graph(); $g->title($this->lang->line('Projects added last 6 months'), '{font-size: 20px; color: #999999}'); // we add 2 sets of data: $g->set_data($data_1); $g->set_bg_colour('0xFFFFFF'); // we add the 3 line types and key labels $g->line_dot(3, 5, 'FF6633', 'Projects', 12); // <-- 3px thick + dots $g->set_x_labels($mon); $g->set_x_label_style(10, '0x000000', 0, 1); $g->set_y_max(50); $g->y_label_steps(4); echo $g->render(); }
$max = 0; for ($i = -4; $i < 1; $i++) { $date = date('Y-m-d', strtotime($i . ' days')); if ($i == 0) { $daysRow[] = t('Today'); } else { $daysRow[] = strftime('%a', strtotime($i . ' days')); } $total = PageStatistics::getTotalPageViewsForOthers($u, $date); $viewsArray[] = $total; if ($total > $max) { $max = $total; } } $g = new graph(); $g->set_title(' ', '{color: #ffffff}'); $g->set_data($viewsArray); $g->bg_colour = '#ffffff'; $g->set_inner_background('#ffffff', "#cccccc", 90); // we add the 3 line types and key labels $g->line_dot(3, 5, '#4C85BB', false, 10); $g->set_x_labels($daysRow); $g->set_x_label_style(10, '#ababab', 0, 2); $g->x_axis_colour('#333333', '#bebebe'); $g->y_axis_colour('#333333', '#bebebe'); $g->set_y_max($max); $g->num_decimals = 0; $g->is_fixed_num_decimals_forced = true; $g->y_label_steps(5); $g->set_y_legend(t('Views'), 12, '#333333'); echo $g->render();
} $data_date = array(); for ($i = 0; $i < $report->size; $i++) { $data_date[] = $report->info[$i]['text']; } // use the chart class to build the chart: include_once DIR_WS_CLASSES . 'ofc-library/open-flash-chart.php'; $g = new graph(); $g->bg_colour = '0xFFFFFF'; $g->x_grid_colour = '0xd8d8d8'; $g->y_grid_colour = '0xd8d8d8'; $g->title(HEADING_TITLE . ': ' . $report_desc, '{font-size: 18px;}'); $g->set_data($data_count); $g->line_hollow(3, 4, '0x0077cc', TEXT_NUMBER_OF_ORDERS, 12); $g->set_data($data_sum); $g->line_dot(3, 4, '0xff9900', TEXT_TOTAL_SUMM, 12); // // Attach the second data line (Free Ram) to the right axis: // $g->attach_to_y_right_axis(2); // // label each point with its value $g->set_x_labels($data_date); $g->set_x_label_style(10, '0x000000', 0, 2); // set the Y max $g->set_y_max(max($data_count) / 10 + max($data_count)); $g->set_y_right_max(max($data_sum) / 10 + max($data_sum)); // label every 20 (0,20,40,60) $g->y_label_steps(4); // display the data echo $g->render();
$count = 0; while ($row = mysql_fetch_array($result)) { //print_r($row); $added = false; if ($count % $num_obs == 0) { $data[] = $row['amount']; $dates[] = substr($row['last_update'], 0, 10); $added = true; } $count++; if ($count == $num_rows && !$added) { $data[] = $row['amount']; $dates[] = substr($row['last_update'], 0, 10); $added = true; } } $min = 0.85 * min($data); $max = 1.15 * max($data); // set the data $g->set_data($data); // new line_dot object $g->line_dot(3, 5, '#666666', "Total Value"); // x-axis $g->set_x_labels(dates); $g->set_x_label_style(10, '#0000FF', 2); // y-axis $g->set_y_max($max); $g->set_y_min($min); $g->y_label_steps(10); $g->set_y_legend('Amount ($)', 12, '#336666'); echo $g->render;