include 'include.php'; $this_month = ' -w -J --forecast "d<=[today]+365" -d "d>=[next month] & d<=[today]+365" --sort d reg FirstTech:Checking'; exec("{$ledger} {$this_month}", $output); foreach ($output as $line) { $tmp = explode(" ", $line); $datalist[] = 1 * $tmp[1]; $labellist[] = $tmp[0]; } //Prevent error on no data if (count($datalist < 1)) { $datalist[] = 0; $labellist[] = 0; } $title = new title("Checking account forecast"); $default_dot = new dot(); $default_dot->tooltip('$#val#'); $line = new line(); $line->set_values($datalist); $line->set_default_dot_style($default_dot); $x_labels = new x_axis_labels(); $x_labels->rotate(45); $x_labels->set_labels($labellist); $x_labels->set_steps(3); $x = new x_axis(); $x->set_labels($x_labels); $y = new y_axis(); $y->set_range(min(min($datalist) - 10, 0), round(max($datalist) * 1.1)); $y->set_label_text("\$#val#"); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($line);
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(); }
// Nouveau grAphique $chart = new open_flash_chart(); $title = new title("Classement General"); $chart->set_title($title); $chart->set_y_axis($y); $chart->set_x_axis($x); //$posy=0; for ($j = 0; $j < sizeof($listeJoueurs); $j++) { $type = new dot(); // if ($posy==0) $type = new dot(); // else if ($posy==1) $type = new solid_dot(); // else if ($posy==2) $type = new hollow_dot(); // else if ($posy==3) $type = new star(); // else if ($posy==4) $type = new anchor(); // else if ($posy==5) $type = new bow(); $type->tooltip($listeJoueurs[$j]['nom'] . "<br>Jeu:#x_label#<br>Moy. #val#"); $line = new line(); $line->set_default_dot_style($type); $line->set_width(1); $line->set_colour($G_MesCouleurs[$j]); $line->set_values($data_val[$j]); $line->set_key($listeJoueurs[$j]["nom"], 10); $chart->add_element($line); //$posy=$posy+1; //if ($posy==6) $posy=0; } // Tooltip du graphe ! $chart->set_tooltip($t); $fp = fopen($fichierImage, "w"); // ouverture du fichier en écriture fputs($fp, $chart->toPrettyString());
if ($qty > $data_max) { $data_max = $qty; } } $line_4 = new line(); $line_4->set_values($data_4); $line_4->set_colour($data_4_color); $line_4->set_width(1); //CREATE DATA 5 (SOLD HISTORY QTY) $data_5_color = '#ff69b4'; $data_5 = array(); foreach ($daily_sold as $date => $qty) { $kw = $k + 1; $lv = new dot($qty); $lv->colour($data_5_color)->size(1); $lv->tooltip('Order Qty (#x_label#) = #val# .'); $data_5[] = $lv; if ($qty > $data_max) { $data_max = $qty; } } $line_5 = new line(); $line_5->set_values($data_5); $line_5->set_colour($data_5_color); $line_5->set_width(1); //CHECK MAX VALUE TO DEFINE BEST VERTICAL STEPS if ($data_max <= 10) { $data_step = 1; } else { $data_step_multiplier = pow(10, strlen((string) $data_max) - 1); if ($data_max > 5 * $data_step_multiplier) {
function get_daily_entries($form, $colors = false, $type = "DATE") { global $wpdb, $frmdb; if (!$colors) { $colors = array('#EF8C08', '#21759B', '#1C9E05'); } $type = strtoupper($type); //Chart for Entries Submitted $values = array(); $labels = array(); if ($type == 'HOUR') { $start_timestamp = strtotime('-48 hours'); } else { if ($type == 'MONTH') { $start_timestamp = strtotime('-1 year'); } else { if ($type == 'YEAR') { $start_timestamp = strtotime('-10 years'); } else { $start_timestamp = strtotime('-1 month'); } } } $end_timestamp = time(); if ($type == 'HOUR') { $query = "SELECT en.created_at as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j H", $start_timestamp) . ":00:00' AND en.form_id={$form->id} GROUP BY endate"; } else { $query = "SELECT DATE(en.created_at) as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j", $start_timestamp) . " 00:00:00' AND en.form_id={$form->id} GROUP BY {$type}(en.created_at)"; } $entries_array = $wpdb->get_results($query); $temp_array = $counts_array = $dates_array = array(); // Refactor Array for use later on foreach ($entries_array as $e) { $e_key = $e->endate; if ($type == 'HOUR') { $e_key = date('Y-m-d H', strtotime($e->endate)) . ':00:00'; } else { if ($type == 'MONTH') { $e_key = date('Y-m', strtotime($e->endate)) . '-01'; } else { if ($type == 'YEAR') { $e_key = date('Y', strtotime($e->endate)) . '-01-01'; } } } $temp_array[$e_key] = $e->encount; } // Get the dates array if ($type == 'HOUR') { for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60) { if (!in_array(date('Y-m-d H', $e) . ':00:00', $dates_array)) { $dates_array[] = date('Y-m-d H', $e) . ':00:00'; } } $date_format = get_option('time_format'); } else { if ($type == 'MONTH') { for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 25) { if (!in_array(date('Y-m', $e) . '-01', $dates_array)) { $dates_array[] = date('Y-m', $e) . '-01'; } } $date_format = 'F Y'; } else { if ($type == 'YEAR') { for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 364) { if (!in_array(date('Y', $e) . '-01-01', $dates_array)) { $dates_array[] = date('Y', $e) . '-01-01'; } } $date_format = 'Y'; } else { for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24) { $dates_array[] = date("Y-m-d", $e); } $date_format = get_option('date_format'); } } } // Make sure counts array is in order and includes zero click days foreach ($dates_array as $date_str) { if (isset($temp_array[$date_str])) { $counts_array[$date_str] = $temp_array[$date_str]; } else { $counts_array[$date_str] = 0; } } foreach ($counts_array as $date => $count) { $labels[] = date_i18n($date_format, strtotime($date)); $values[] = (int) $count; } if ($type == 'MONTH') { $title = __('Monthly Entries', 'formidable'); } else { if ($type == 'YEAR') { $title = __('Yearly Entries', 'formidable'); } else { if ($type == 'HOUR') { $title = __('Hourly Entries', 'formidable'); } else { $title = __('Daily Entries', 'formidable'); } } } $title = new title($title); $line_1_default_dot = new dot(); $line_1_default_dot->colour($colors[0]); $line_1_default_dot->tooltip('#x_label#<br>#val# Entries'); $line_1 = new line(); $line_1->set_default_dot_style($line_1_default_dot); $line_1->set_values($values); $line_1->set_colour($colors[1]); $chart = new open_flash_chart(); $chart->set_title($title); $chart->set_bg_colour('#FFFFFF'); $x = new x_axis(); $x_labels = new x_axis_labels(); $x_labels->rotate(340); $x_labels->set_labels($labels); if (count($labels) > 15) { $x_labels->visible_steps(2); } $x->set_labels($x_labels); $chart->set_x_axis($x); $y = new y_axis(); if (!empty($values)) { $max = max($values) + 1; $step = ceil($max / 10); $y->set_range(0, $max, $step); } $chart->add_element($line_1); $chart->set_y_axis($y); return $chart->toPrettyString(); }