$lineplot_in->SetLegend('Traffic In'); $lineplot_in->SetColor('darkgreen'); $lineplot_in->SetFillColor('lightgreen@0.4'); $lineplot_in->SetWeight(1); $lineplot_out = new LinePlot($out_data_inv, $ticks); $lineplot_out->SetLegend('Traffic Out'); $lineplot_out->SetColor('darkblue'); $lineplot_out->SetFillColor('lightblue@0.4'); $lineplot_out->SetWeight(1); if ($_GET['95th']) { $lineplot_95th = new LinePlot($per_data, $ticks); $lineplot_95th->SetColor('red'); } if ($_GET['ave']) { $lineplot_ave = new LinePlot($ave_data, $ticks); $lineplot_ave->SetColor('red'); } $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->Pos(0.52, 0.9, 'center'); $graph->Add($lineplot); // $graph->Add($lineplot2); $graph->Add($lineplot_in); $graph->Add($lineplot_out); if ($_GET['95th']) { $graph->Add($lineplot_95th); } if ($_GET['ave']) { $graph->Add($lineplot_ave); } $graph->stroke();
/** * Collects and renders visitor/week report data */ public function visitor_week() { $myConfig = $this->getConfig(); $oDb = oxDb::getDb(); $aDataX = array(); $aDataX2 = array(); $aDataX3 = array(); $aDataY = array(); $sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to")))); $sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from")))); $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime"; $aTemp = array(); $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { //$aTemp[date( "W", strtotime( $rs->fields[0]))]++; $aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++; $rs->moveNext(); } } // initializing list($iFrom, $iTo) = $this->getWeekRange(); for ($i = $iFrom; $i < $iTo; $i++) { $aDataX[$i] = 0; $aDataX2[$i] = 0; $aDataX3[$i] = 0; $aDataY[] = "KW " . $i; } foreach ($aTemp as $key => $value) { $aDataX[$key] = $value; $aDataX2[$key] = 0; $aDataX3[$key] = 0; $aDataY[] = "KW " . $key; } // buyer $sSQL = "select oxorderdate from oxorder where oxorderdate >= {$sTimeFrom} and oxorderdate <= {$sTimeTo} order by oxorderdate"; $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { $sKey = oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0])); if (isset($aDataX2[$sKey])) { $aDataX2[$sKey]++; } $rs->moveNext(); } } // newcustomer $sSQL = "select oxtime, oxsessid from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime"; $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { $sKey = oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0])); if (isset($aDataX3[$sKey])) { $aDataX3[$sKey]++; } $rs->moveNext(); } } header("Content-type: image/png"); // New graph with a drop shadow $graph = new Graph(max(800, count($aDataX) * 80), 600); $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME); // Use a "text" X-scale $graph->setScale("textlin"); $graph->setY2Scale("lin"); $graph->y2axis->setColor("red"); // Label align for X-axis $graph->xaxis->setLabelAlign('center', 'top', 'right'); // Label align for Y-axis $graph->yaxis->setLabelAlign('right', 'bottom'); $graph->setShadow(); // Description $graph->xaxis->setTickLabels($aDataY); // Set title and subtitle $graph->title->set("Woche"); // Use built in font $graph->title->setFont(FF_FONT1, FS_BOLD); $aDataFinalX = array(); foreach ($aDataX as $dData) { $aDataFinalX[] = $dData; } // Create the bar plot $l2plot = new LinePlot($aDataFinalX); $l2plot->setColor("navy"); $l2plot->setWeight(2); $l2plot->setLegend("Besucher"); $l2plot->value->setColor("navy"); $l2plot->value->setFormat('% d'); $l2plot->value->hideZero(); $l2plot->value->show(); $aDataFinalX2 = array(); foreach ($aDataX2 as $dData) { $aDataFinalX2[] = $dData; } // Create the bar plot $l3plot = new LinePlot($aDataFinalX2); $l3plot->setColor("orange"); $l3plot->setWeight(2); $l3plot->setLegend("Bestellungen"); //$l1plot->SetBarCenter(); $l3plot->value->setColor("orange"); $l3plot->value->setFormat('% d'); $l3plot->value->hideZero(); $l3plot->value->show(); //conversion rate graph $l1datay = array(); for ($iCtr = 0; $iCtr < count($aDataFinalX); $iCtr++) { if ($aDataFinalX[$iCtr] != 0 && $aDataFinalX2[$iCtr] != 0) { $l1datay[] = 100 / ($aDataFinalX[$iCtr] / $aDataFinalX2[$iCtr]); } else { $l1datay[] = 0; } } $l1plot = new LinePlot($l1datay); $l1plot->setColor("red"); $l1plot->setWeight(2); $l1plot->setLegend("Conversion rate (%)"); $l1plot->value->setColor('red'); $l1plot->value->setFormat('% 0.4f%%'); $l1plot->value->hideZero(); $l1plot->value->show(); // Create the grouped bar plot $graph->addY2($l1plot); $graph->add($l2plot); $graph->add($l3plot); // Finally output the image $graph->stroke(); }
require_once './jpgraph-3.5.0b1/src/jpgraph_line.php'; // 获取graph对象,填写画布宽高 $graph = new Graph(400, 400); // 设置X和Y轴样式 $graph->SetScale("textint"); // 设置图像标题 $graph->title->SetFont(FF_CHINESE); $graph->title->Set('This is jasongjiang Test'); // 设置数据 $data = array(0 => 21, 1 => 21, 2 => 45, 3 => 88, 4 => 55); // 得到实例 $linePlot = new LinePlot($data); $linePlot->SetLegend('测试中文'); // 将曲线加入到画布中 $graph->Add($linePlot); // 修改线条颜色 $linePlot->SetColor('red'); $AT = $graph->stroke(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php ?> </title> </head> <body> </body> </html>
/** * Current week top search strings report */ public function graph1() { $myConfig = $this->getConfig(); $oDb = oxDb::getDb(); $aDataX = array(); $aDataY = array(); $sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from")))); $sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to")))); $sSQL = "select count(*) as nrof, oxparameter from oxlogs where oxclass = 'search' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxparameter order by nrof desc"; $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { if ($rs->fields[1]) { $aDataX[] = $rs->fields[0]; $aDataY[] = $rs->fields[1]; } $rs->moveNext(); } } header("Content-type: image/png"); // New graph with a drop shadow $graph = new Graph(800, max(640, 20 * count($aDataX))); $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME); // Use a "text" X-scale $graph->setScale("textlin"); $top = 60; $bottom = 30; $left = 80; $right = 30; $graph->set90AndMargin($left, $right, $top, $bottom); // Label align for X-axis $graph->xaxis->setLabelAlign('right', 'center', 'right'); // Label align for Y-axis $graph->yaxis->setLabelAlign('center', 'bottom'); $graph->setShadow(); // Description $graph->xaxis->setTickLabels($aDataY); // Set title and subtitle $graph->title->set("Suchw�rter"); // Use built in font $graph->title->setFont(FF_FONT1, FS_BOLD); // Create the bar plot $bplot = new BarPlot($aDataX); $bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER); $bplot->setLegend("Hits"); $graph->add($bplot); // Finally output the image $graph->stroke(); }
/** * Collects and renders visitor/week report data */ public function visitor_week() { $myConfig = $this->getConfig(); $oDb = oxDb::getDb(); $aDataX = array(); $aDataY = array(); $sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to")))); $sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from")))); $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime"; $aTemp = array(); $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { //$aTemp[date( "W", strtotime( $rs->fields[0]))]++; $aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++; $rs->moveNext(); } } // initializing list($iFrom, $iTo) = $this->getWeekRange(); for ($i = $iFrom; $i < $iTo; $i++) { $aDataX[$i] = 0; $aDataX2[$i] = 0; $aDataX3[$i] = 0; $aDataY[] = "KW " . $i; } foreach ($aTemp as $key => $value) { $aDataX[$key] = $value; $aDataX2[$key] = 0; $aDataX3[$key] = 0; $aDataY[] = "KW " . $key; } // buyer $sSQL = "select oxorderdate from oxorder where oxorderdate >= {$sTimeFrom} and oxorderdate <= {$sTimeTo} order by oxorderdate"; $aTemp = array(); $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { //$aTemp[date( "W", strtotime( $rs->fields[0]))]++; $aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++; $rs->moveNext(); } } foreach ($aTemp as $key => $value) { $aDataX2[$key] = $value; } // newcustomer $sSQL = "select oxcreate from oxuser where oxcreate >= {$sTimeFrom} and oxcreate <= {$sTimeTo} order by oxcreate"; $aTemp = array(); $rs = $oDb->execute($sSQL); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { //$aTemp[date( "W", strtotime( $rs->fields[0]))]++; $aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++; $rs->moveNext(); } } foreach ($aTemp as $key => $value) { $aDataX3[$key] = $value; } header("Content-type: image/png"); // New graph with a drop shadow $graph = new Graph(max(800, count($aDataX) * 80), 600); $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME); // Use a "text" X-scale $graph->setScale("textlin"); // Label align for X-axis $graph->xaxis->setLabelAlign('center', 'top', 'right'); // Label align for Y-axis $graph->yaxis->setLabelAlign('right', 'bottom'); $graph->setShadow(); // Description $graph->xaxis->setTickLabels($aDataY); // Set title and subtitle $graph->title->set("Woche"); // Use built in font $graph->title->setFont(FF_FONT1, FS_BOLD); $aDataFinalX = array(); foreach ($aDataX as $dData) { $aDataFinalX[] = $dData; } // Create the bar plot $bplot = new BarPlot($aDataFinalX); $bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER); $bplot->setLegend("Besucher"); $aDataFinalX2 = array(); foreach ($aDataX2 as $dData) { $aDataFinalX2[] = $dData; } // Create the bar plot $bplot2 = new BarPlot($aDataFinalX2); $bplot2->setFillColor("orange"); $bplot2->setLegend("Kaeufer"); $aDataFinalX3 = array(); foreach ($aDataX3 as $dData) { $aDataFinalX3[] = $dData; } // Create the bar plot $bplot3 = new BarPlot($aDataFinalX3); $bplot3->setFillColor("silver"); $bplot3->setLegend("Neukunden"); // Create the grouped bar plot $gbplot = new groupBarPlot(array($bplot, $bplot2, $bplot3)); $graph->add($gbplot); // Finally output the image $graph->stroke(); }
public function generateLog($winner = false) { $gameid = strtotime('now'); $template = file_get_contents('data/log.html'); $fp = fopen(sprintf('logs/log_%d.html', $gameid), 'a'); $htplayers = array(); foreach ($this->players as $pl) { $htplayers[] = sprintf('<li>%s</li>', htmlspecialchars(parent::playerName($pl))); } $players = implode("\n", $htplayers); if ($winner) { $data = sprintf("After %d hands played, the player <strong>%s</strong> won the total pot of <strong>\$%0.2f</strong>", $this->game, parent::playerName($winner), $winner->money); } else { $htplayers = array(); foreach ($this->players as $pl) { $htplayers[] = sprintf('<li>%s ($%0.2f)</li>', htmlspecialchars(parent::playerName($pl)), $pl->money); } $htplayers = implode("\n", $htplayers); $data = sprintf("After %d hands no winner was determined a summary of each individual player's money follows:<ol>%s</ol>", $this->game, $htplayers); } $template = str_replace("{players}", $players, $template); $template = str_replace("{gameid}", $gameid, $template); $template = str_replace("{winner}", $data, $template); $template = str_replace("{version}", parent::$version, $template); $template = str_replace("{date}", date('d-m-Y h:i', $gameid), $template); $template = str_replace("{startmoney}", sprintf('%0.2f', $this->playermoney), $template); $template = str_replace("{bigblind}", sprintf('%0.2f', $this->bigblind), $template); $template = str_replace("{smallblind}", sprintf('%0.2f', $this->smallblind), $template); $template = str_replace("{maxgames}", $this->totalgames, $template); $template = str_replace("{winner}", $data, $template, $template); fputs($fp, $template); fclose($fp); require_once 'data/jpgraph.php'; require_once 'data/jpgraph_line.php'; $width = 900; $height = 300; $graph = new Graph($width, $height); $graph->img->SetMargin(40, 40, 40, 40); $graph->SetShadow(); $graph->setScale('intlin'); $graph->title->Set('Amount of money per player, per hand'); $graph->xaxis->title->Set('Hand'); $graph->yaxis->title->Set('Money'); foreach ($this->moneylog as $id => $data) { $p = $this->players[$id]; $lineplot = new LinePlot($data); $lineplot->setweight($id); $lineplot->SetLegend(parent::playerName($p)); $graph->add($lineplot); } $graph->stroke(sprintf('logs/playermoney_%d.jpg', $gameid)); // Pie graph, showing checks, folds, bets, wins, calls and raises require_once "data/jpgraph_pie.php"; // Create the Pie Graph. $height = ceil(count($this->players) / 2) * 440; $graph = new PieGraph($width, $height); $graph->SetShadow(); // Set A title for the plot $graph->title->Set("Moves per user"); // Create plots $size = 0.2; $x = array(0.25, 0.75); $y = 220; $i = 1; $legend = array("Check", "Call", "Bet", "Raise", "Fold"); foreach ($this->players as $id => $player) { $plot = new PiePlot(array($player->checks, $player->calls, $player->bets, $player->raises, $player->folds)); if ($player->id == 1) { $plot->SetLegends($legend); } $plot->SetLabelType(PIE_VALUE_ADJPERCENTAGE); $plot->SetSize($size); $plot->SetCenter($x[$i - 1], $y); if ($i == 2) { $i = 0; $y += 420; } $i++; $plot->title->Set(parent::playerName($player)); $graph->add($plot); } $graph->stroke(sprintf('logs/playermoves_%d.jpg', $gameid)); // Bargraph containing each player's wins $height = 70 * count($this->players); require_once "data/jpgraph_bar.php"; $graph = new Graph($width, $height); $graph->SetScale('textlin'); $graph->SetShadow(); $lbl = array(); $data = array(); foreach ($this->players as $pl) { $lbl[] = parent::PlayerName($pl); $data[] = $pl->wins; } $top = 60; $bottom = 30; $left = 80; $right = 30; $graph->Set90AndMargin($left, $right, $top, $bottom); $graph->xaxis->SetTickLabels($lbl); $graph->xaxis->SetLabelAlign('right', 'center', 'right'); $graph->yaxis->SetLabelAlign('center', 'bottom'); $graph->title->Set('Amount of hands won by individual players'); $bplot = new BarPlot($data); $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_HOR); $bplot->SetWidth(0.5); $bplot->SetYMin(0); $graph->Add($bplot); $graph->Stroke(sprintf('logs/playerwins_%d.jpg', $gameid)); $this->newgame = false; // Remove the clients from the server $this->broadcast("[SERVER] Thank you for playing Texas Hold`em (LIMIT)\n[SERVER] If you want to play another game, just reconnect to the server!"); $this->return = true; foreach ($this->players as $player) { $this->disconnect($player); } $this->return = true; $this->restore(); }
private function graphB(WC_Site $site, $field) { $graphtitle = $this->module->lang('gt_site_' . $field, array($site->getVar('site_name'))); $siteid = $site->getID(); $history = GDO::table('WC_HistorySite'); if (false === ($result = $history->select("sitehist_date, {$field}", 'sitehist_sid=' . $siteid, 'sitehist_date ASC'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // $db = gdo_db(); // $table = $history->getTableName(); // if (false === ($result = $db->query("SELECT sitehist_date, $field FROM $table WHERE sitehist_sid=$siteid ORDER BY sitehist_date ASC"))) { // return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); // } //load in the data $xdataarray = array(); $ydataarray = array(); $highestvalue = 0; // while (false !== ($row = $db->fetchRow($result))) while (false !== ($row = $history->fetch($result, GDO::ARRAY_N))) { $value = (int) $row[1]; $xdataarray[] = $row[0]; $ydataarray[] = $value; if ($value > $highestvalue) { $highestvalue = $value; } } $history->free($result); // add current value $xdataarray[] = time(); $ydataarray[] = $value = $site->getVar(str_replace('hist_', '_', $field)); if ($value > $highestvalue) { $highestvalue = $value; } // var_dump($xdataarray); // var_dump($ydataarray); // var_dump($xticks); if ($highestvalue === 0) { $graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight()); $graph->SetScale('intlin', 1, 2, 1, 2); $caption = new Text($this->module->lang('err_graph_empty'), 0.1, 0.8); // $caption->SetFont(FS_BOLD); $graph->AddText($caption); $graph->stroke(); die(0); } # $dateformat = GWF_HTML::lang('df_8'); // $dateformat = "d.M.y-H:i"; $dateformat = "M.y"; $datemargin = strlen(date($dateformat)) * 11; //define the graph $graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight()); $graph->SetScale('datlin', 0, 1.05 * $highestvalue); $graph->title->Set($graphtitle); // $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12); $graph->SetColor(array(238, 238, 238)); $graph->SetMarginColor(array(208, 211, 237)); $graph->SetShadow(); $graph->xaxis->SetLabelAngle(90); // $graph->xaxis->SetTickPositions($xticks, NULL, $xdataarray); $graph->xaxis->scale->SetDateFormat($dateformat); $graph->img->SetMargin(50, 40, 40, $datemargin); $lineplot = new LinePlot($ydataarray, $xdataarray); $lineplot->SetColor("blue"); $lineplot->SetWeight(2); $graph->Add($lineplot); // $graph->img->SetAntiAliasing(); // Display the graph GWF_HTTP::noCache(); $graph->Stroke(); die(0); }
DEFINE("TTF_DIR", "./"); require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_line.php"; require_once "jpgraph/jpgraph_date.php"; require_once "fonction.php"; $link = connect(); $query = "SELECT * FROM `humidity` ORDER BY `index` ASC"; $res = requete($query, $link); $i = 0; while ($tab = mysql_fetch_array($res)) { $data[] = $tab['val']; $xdata[] = strtotime($tab['date']); } #$data1 = array(12,23,9,58,23,26,57,48,12); //// Initialisation du graphique $graphe = new Graph(480, 280); $graphe->SetMargin(40, 10, 10, 80); $graphe->setScale("datlin", 0, 800); $graphe->xaxis->SetFont(FF_VERA, FS_NORMAL, 8); $graphe->xaxis->SetLabelAngle(50); $graphe->xaxis->scale->SetDateFormat('M:d'); // Creation de l'histogramme $line1 = new LinePlot($data, $xdata); // Ajout de l'histogramme au graphique $graphe->add($line1); // Ajout du titre du graphique //$graphe->title->set("Courbe d'humidite"); // Affichage du graphique $graphe->stroke();