function execute() { $this->set_title('Statistics Center'); $this->tree('Statistics Center'); if (!extension_loaded('gd')) { return $this->message('JpGraph Error', 'You need to install the correct GD libraries to run the Statistics centre (GD Libraries were not detected)'); } include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; if (!defined('IMG_PNG')) { return $this->message('JpGraph Error', 'This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)'); } /** * Posts */ $query = $this->db->query("\r\n\t\tSELECT\r\n\t\t COUNT(post_id) AS posts,\r\n\t\t FROM_UNIXTIME(post_time, '%b %y') AS month\r\n\t\tFROM {$this->pre}posts\r\n\t\tGROUP BY month\r\n\t\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set('Posts by Month'); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("\r\n\t\tSELECT\r\n\t\t COUNT(user_id) AS users,\r\n\t\t FROM_UNIXTIME(user_joined, '%b %y') AS month\r\n\t\tFROM {$this->pre}users\r\n\t\tWHERE user_joined != 0\r\n\t\tGROUP BY month\r\n\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set('Registrations by Month'); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}2.png"); return $this->message('Statistics Center', "<img src='{$this->time}1.png' alt='Posts by Month' /><br /><br />\r\n\t\t<img src='{$this->time}2.png' alt='Registrations by Month' />"); }
function execute() { $this->set_title($this->lang->stats); $this->tree($this->lang->stats); include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; if (!defined('IMG_PNG')) { JpGraphError::Raise("This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)"); } /** * Posts */ $query = $this->db->query("SELECT COUNT(post_id) AS posts, FROM_UNIXTIME(post_time, '%%b %%y') AS month\n\t\t\tFROM %pposts GROUP BY month\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_post_by_month); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("../stats/{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("SELECT COUNT(user_id) AS users, FROM_UNIXTIME(user_joined, '%%b %%y') AS month\n\t\t\tFROM %pusers\n\t\t\tWHERE user_joined != 0\n\t\t\tGROUP BY month\n\t\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_reg_by_month); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("../stats/{$this->time}2.png"); return $this->message($this->lang->stats, "<img src='../stats/{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='../stats/{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />"); }
function execute() { $this->set_title($this->lang->stats); $this->tree($this->lang->stats); include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; /** * Posts */ $query = $this->db->query("\n\t\tSELECT\n\t\t COUNT(post_id) AS posts,\n\t\t FROM_UNIXTIME(post_time, '%b %y') AS month\n\t\tFROM {$this->pre}posts\n\t\tGROUP BY month\n\t\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_post_by_month); $barplot = new BarPlot(array_values($data)); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("\n\t\tSELECT\n\t\t COUNT(user_id) AS users,\n\t\t FROM_UNIXTIME(user_joined, '%b %y') AS month\n\t\tFROM {$this->pre}users\n\t\tWHERE user_joined != 0\n\t\tGROUP BY month\n\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_reg_by_month); $barplot = new BarPlot(array_values($data)); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}2.png"); return $this->message($this->lang->stats, "<img src='{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />"); }
include "../../../include/network.php"; $nt = new NetworkTable("IA_RWIS"); $cities = $nt->table; // Create the graph. These two calls are always required $graph = new Graph(650, 550, "example1"); $graph->SetScale("datlin"); $graph->SetMarginColor("white"); $graph->SetColor("lightyellow"); $graph->img->SetMargin(40, 55, 105, 105); //$graph->xaxis->SetFont(FS_FONT1,FS_BOLD); $graph->yaxis->SetTitle("Average Speed [mph]"); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->xaxis->SetTitle("Time Period: " . date('Y-m-d h:i A', $times[0][0]) . " thru " . date('Y-m-d h:i A', max($times[0]))); $graph->xaxis->SetTitleMargin(67); $graph->xaxis->title->SetFont(FF_VERA, FS_BOLD, 12); $graph->xaxis->title->SetColor("brown"); $graph->xaxis->SetPos("min"); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelFormatString("M-j h A", true); $graph->legend->Pos(0.01, 0.01); $graph->legend->SetLayout(LEGEND_VERT); $colors = array(0 => "green", 1 => "black", 2 => "blue", 3 => "red", 4 => "purple", 5 => "tan", 6 => "pink", 7 => "lavendar"); while (list($k, $v) = each($times)) { // Create the linear plot $lineplot = new LinePlot($avg_speed[$k], $times[$k]); $lineplot->SetLegend($labels[$k]); $lineplot->SetColor($colors[$k]); $lineplot->SetWeight(3); $graph->add($lineplot); } $graph->Stroke();
/** * Build a graph onto disk using Artichow library * @param file Image file name on disk */ function draw_artichow($file) { dol_syslog("DolGraph.class::draw_artichow this->type=".$this->type); if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3); if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2); if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1); // Create graph $classname=''; if ($this->type == 'bars') $classname='BarPlot'; if ($this->type == 'lines') $classname='LinePlot'; include_once DOL_DOCUMENT_ROOT."/includes/artichow/".$classname.".class.php"; // Definition de couleurs $bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]); $bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]); $colortrans=new Color(0,0,0,100); $colorsemitrans=new Color(255,255,255,60); $colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0); $colorwhite=new Color(255,255,255); // Graph $graph = new Graph($this->width, $this->height); $graph->border->hide(); $graph->setAntiAliasing(true); if (isset($this->title)) { $graph->title->set($this->title); $graph->title->setFont(new Tuffy(10)); } if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor); else $graph->setBackgroundGradient($colorgradient); $group = new PlotGroup; //$group->setSpace(5, 5, 0, 0); $paddleft=50; $paddright=10; $strl=dol_strlen(max(abs($this->MaxValue),abs($this->MinValue))); if ($strl > 6) $paddleft += ($strln * 4); $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values $group->legend->setSpace(0); $group->legend->setPadding(2,2,2,2); $group->legend->setPosition(NULL,0.1); $group->legend->setBackgroundColor($colorsemitrans); if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid); else $group->grid->setBackgroundColor($colortrans); if ($this->hideXGrid) $group->grid->hideVertical(true); if ($this->hideYGrid) $group->grid->hideHorizontal(true); // On boucle sur chaque lot de donnees $legends=array(); $i=0; $nblot=sizeof($this->data[0])-1; while ($i < $nblot) { $j=0; $values=array(); foreach($this->data as $key => $valarray) { $legends[$j] = $valarray[0]; $values[$j] = $valarray[$i+1]; $j++; } // Artichow ne gere pas les valeurs inconnues // Donc si inconnu, on la fixe a null $newvalues=array(); foreach($values as $val) { $newvalues[]=(is_numeric($val) ? $val : null); } if ($this->type == 'bars') { //print "Lot de donnees $i<br>"; //print_r($values); //print '<br>'; $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20); $colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50); $colorgrey=new Color(100,100,100); $colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]); if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot); if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5); $plot->barBorder->setColor($colorgrey); //$plot->setBarColor($color); $plot->setBarGradient( new LinearGradient($colorbis, $color, 90) ); if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1); if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4); if ($this->mode == 'side') $plot->setBarSpace(5); if ($this->mode == 'depth') $plot->setBarSpace(2); $plot->barShadow->setSize($this->SetShading); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(160, 160, 160, 50)); $plot->barShadow->smooth(TRUE); //$plot->setSize(1, 0.96); //$plot->setCenter(0.5, 0.52); // Le mode automatique est plus efficace $plot->SetYMax($this->MaxValue); $plot->SetYMin($this->MinValue); } if ($this->type == 'lines') { $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20); $colorbis=new Color(min($this->datacolor[$i][0]+20,255),min($this->datacolor[$i][1]+20,255),min($this->datacolor[$i][2]+20,255),60); $colorter=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),90); $plot = new LinePlot($newvalues); //$plot->setSize(1, 0.96); //$plot->setCenter(0.5, 0.52); $plot->setColor($color); $plot->setThickness(1); // Set line background gradient $plot->setFillGradient( new LinearGradient($colorter, $colorbis, 90) ); $plot->xAxis->setLabelText($legends); // Le mode automatique est plus efficace $plot->SetYMax($this->MaxValue); $plot->SetYMin($this->MinValue); //$plot->setYAxis(0); //$plot->hideLine(true); } //$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures $group->legend->setTextFont(new Tuffy(10)); // This is to force Artichow to use awFileFontDriver to // solve a bug in Artichow with UTF8 if (sizeof($this->Legend)) { if ($this->type == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND); if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE); } $group->add($plot); $i++; } $group->axis->bottom->setLabelText($legends); $group->axis->bottom->label->setFont(new Tuffy(7)); //print $group->axis->bottom->getLabelNumber(); if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval); $graph->add($group); // Generate file $graph->draw($file); }
protected function getImage_p($id) { require_once "./protected/pages/components/velopark/artichow/Pie.class.php"; $sql = "SELECT id, area,filling, name FROM hr_vp_parking "; $cmd = $this->db->createCommand($sql); $data = $cmd->query(); $data = $data->read(); $graph = new Graph(500, 300); $graph->setBackgroundGradient(new LinearGradient(new White(), new VeryLightGray(40), 0)); $graph->title->set(Prado::localize("Service {name}", array("name" => utf8_decode($data['name'])))); $graph->shadow->setSize(3); $graph->shadow->smooth(TRUE); $graph->shadow->setPosition(Shadow::RIGHT_BOTTOM); $graph->shadow->setColor(new DarkGray()); $values = array($data['filling'], $data['area'] - $data['filling'] + 1.0E-9); //$values = array(22.0,0.000000001); $colors = array(new LightRed(), new LightGreen()); $plot = new Pie($values, $colors); $plot->setCenter(0.42, 0.55); $plot->setSize(0.7, 0.7); $plot->set3D(20); /*if($data['filling']>0) $plot->explode(array(1 => 10));*/ $plot->setLegend(array(utf8_decode(Prado::localize('Used')), utf8_decode(Prado::localize('Free')))); $plot->legend->setPosition(1.3); $plot->legend->shadow->setSize(0); $plot->legend->setBackgroundColor(new VeryLightGray(30)); $graph->add($plot); $graph->draw(); exit; }
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../LinePlot.class.php"; function color($a = NULL) { if ($a === NULL) { $a = mt_rand(20, 80); } return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a); } $graph = new Graph(400, 400, "Abel", time() + 5); $graph->setTiming(TRUE); $graph->setAntiAliasing(TRUE); $x = array(); for ($i = 0; $i < 10; $i++) { $x[] = mt_rand(0, 100); } $plot = new LinePlot($x); $plot->setThickness(1); $plot->setColor(color()); $plot->setFillGradient(new LinearGradient(color(), color(), 0)); $plot->grid->setType(LINE_DASHED); $plot->setYMin(mt_rand(-20, 0)); $plot->yAxis->setLabelNumber(mt_rand(0, 10)); $plot->yAxis->setLabelPrecision(1); $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->setNumberByTick('minor', 'major', 2); $plot->setXAxisZero((bool) mt_rand(0, 1)); $graph->add($plot); $graph->draw();
} $trendline = new LinePlot($avg, $xdata); $trendline->SetWeight(2); $graph->AddLine($trendline); } //Weekends if ($starttime > strtotime('-13 months', $endtime)) { for ($i = 0; $i < count($xdata); $i++) { $rtime = $xdata[$i]; //get start time of this day $start = mktime(0, 0, 0, date('n', $rtime), date('j', $rtime), date('Y', $rtime)); if (date('w', $rtime) == 6) { $end = $start + 60 * 60 * 24 * 2; $band = new PlotBand(VERTICAL, BAND_SOLID, $start, $end, 'lightgray@0.7'); $band->ShowFrame(false); $graph->add($band); } $year = date('Y', $rtime); $holidays['nieuwjaarsdag'] = strtotime('1 January ' . $year); $holidays['nieuwjaarsdag2'] = strtotime('2 January ' . $year); $holidays['pasen'] = easter_date($year); $holidays['paasmaandag'] = strtotime('+1 day', $holidays['pasen']); $holidays['olhhemelvaart'] = strtotime('+39 days', $holidays['pasen']); $holidays['olhhemelvaart2'] = strtotime('+1day', $holidays['olhhemelvaart']); $holidays['pinksteren'] = strtotime('+49 days', $holidays['pasen']); $holidays['pinkstermaandag'] = strtotime('+1 day', $holidays['pinksteren']); $holidays['guldensporenslag'] = strtotime('11 July ' . $year); $holidays['nationale_feestdag'] = strtotime('21 July ' . $year); $holidays['allerheiligen'] = strtotime('1 November ' . $year); $holidays['allerzielen'] = strtotime('2 November ' . $year); $holidays['wapenstilstand'] = strtotime('11 November ' . $year);
// remplacer 1.0.9 par setBorderColor // $pie->setBorder(new Black()); $pie->setBorderColor(new Black()); // mode 3D du camembert $pie->set3D(15); // couleur de fond du camembert //$pie->setBackgroundColor(new White(0)); // part à séparer ? //$pie->explode(); // le titre // le texte du titre $pie->title->set($donnee_titre[0]); // emplacement du titre $pie->title->move(10, -20); // police de caractère du titre $pie->title->setFont(new TuffyBold(10)); // le fond de couleur du titre $pie->title->setBackgroundColor(new White(50)); // les espacement dans le cadre du titre $pie->title->setPadding(5, 5, 2, 2); // encadrement du titre $pie->title->border->setColor(new Black()); $graph->add($pie); if ( $export_pdf === 'oui' ) { $graph->draw('../../documents/aa.png'); } else { $graph->draw(); } ?>
<?php require "../../includes.php"; $result = array(&$count, &$date, &$product_id); $stmt = $db->prepare_full("\n\tSELECT\n\t\tSUM(`transaction_contents`.`count`),\n\t\tDATE(`transactions`.`timestamp`) as d,\n\t\tproduct_id\n\tFROM\n\t\t`transaction_contents` JOIN\n\t\t`transactions` ON (`transaction_contents`.`transaction_id` = `transactions`.`transaction_id`)\n\tWHERE\n\t\t`transactions`.`timestamp` > ? AND\n\t\t`transaction_contents`.`product_id` in (?)\n\tGROUP BY\n\t\tDATE(`transactions`.`timestamp`), product_id\n\tORDER BY\n\t\tproduct_id,\n\t\td", $result, 'si', date('Y') - 1 . date('-m-d'), ClientData::request('id')); $image = new Graph(); $image->slide = 7; $image->period = 365; $image->height = 200; $image->width = 730; $image->vertical_lable = 5; $start = gregoriantojd(date('m'), date('d'), date('Y') - 1); $old_product_id = null; while ($stmt->fetch()) { if ($old_product_id != $product_id) { $product = Product::from_id($product_id); } $s_date = explode('-', $date); $image->add($count, gregoriantojd($s_date[1], $s_date[2], $s_date[0]) - $start, $product->name); } $image->draw();
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(); }
/** * 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(); }
function _stats_build_graph($data, $labels, $filename, $stat, $width, $height, $vars) { if (file_exists($filename)) { unlink($filename); } $data_orig = $data; foreach ($data as $key => $val) { if (!is_numeric($val)) { $data[$key] = 0; } } // $vars["color_tab_black"] $bg_grey = _stats_color($vars["bg_grey"], 0); $bg_light_blue = _stats_color($vars["bg_light_blue"], 25); $graph = new Graph($width, $height); $group = new PlotGroup(); $group->setSpace(2, 2); $group->grid->setType(LINE_DASHED); $group->grid->hideVertical(TRUE); $group->setPadding(30, 10, 25, 20); $graph->setBackgroundColor($bg_grey); $graph->title->set($stat); $graph->title->setFont(new Tuffy(10)); $plot = new BarPlot($data, 1, 1, 0); $plot->setBarColor($bg_light_blue); $plot->label->set($data_orig); $plot->label->move(0, -5); $group->add($plot); $group->axis->bottom->setLabelText($labels); $group->axis->bottom->hideTicks(TRUE); $graph->add($group); $graph->draw($filename); }
$xdata = range(0, $numDates - 1); //echo "<pre>";print_r($values);print_r($xdata);echo "</pre>"; $colorIndex = 0; foreach ($values as $currentAccountId => $currentValues) { $line = new LinePlot(array_values($currentValues), $xdata); if ($showTickMarks) { $line->SetCSIMTargets(array_values($valueTargets[$currentAccountId]), array_values($valueNames[$currentAccountId])); $line->mark->SetType(MARK_UTRIANGLE); $line->mark->SetColor($chartColors[$colorIndex % count($chartColors)]); $line->mark->SetFillColor($chartColors[$colorIndex % count($chartColors)]); } $line->SetColor($chartColors[$colorIndex % count($chartColors)]); $line->SetStepStyle(); $line->SetLegend($labels[$currentAccountId]); $colorIndex++; $graph->add($line); } $tickLabels = array(); foreach ($totals as $key => $currentAmount) { $date = new Date($key); $tickLabels[] = $date->getFormatted(); } if (count($values) > 1) { $data = array(); $dataTargets = array(); $dataNames = array(); $previousAmount = null; foreach ($totals as $key => $currentAmount) { $data[] = is_null($previousAmount) || $currentAmount->compare($previousAmount) != 0 || $key == $displayEndDate->getTime() ? $currentAmount->get() : '-'; $date = new Date($key); if ($showTickMarks) {
$targets[$currentCategoryId][] = ''; } } } $colorIndex = 0; $bars = array(); foreach ($labels as $currentCategoryId => $currentLabel) { $bar = new BarPlot($data[$currentCategoryId]); $bar->SetFillColor($chartColors[$colorIndex % count($chartColors)]); $bar->SetLegend($labels[$currentCategoryId]); $bar->SetCSIMTargets($targets[$currentCategoryId], $dataNames[$currentCategoryId]); $bars[] = $bar; $colorIndex++; } $groupBar = new GroupBarPlot($bars); $graph->add($groupBar); $graph->xaxis->SetTickLabels($tickLabels); $graph->xaxis->SetFont(FF_VERA, FS_BOLD); $graph->xaxis->SetColor('black', 'green'); $interval = $numDatas / MAX_LABELS; if ($interval < 1) { $interval = 1; } //echo "numDatas: $numDatas; interval: $interval"; $graph->xaxis->SetTextLabelInterval($interval); $graph->yaxis->SetFont(FF_VERA); $graph->legend->SetFont(FF_VERA); $graph->legend->Pos(0.5, 0.03, 'center', 'top'); $graph->legend->SetColumns(5); $graph->legend->SetHColMargin(10); $graph->SetMargin(80, 20, 60, 20);
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $c; $parameters['interval'] = isset($parameters['interval']) ? $parameters['interval'] : false; $parameters['month_names'] = isset($parameters['month_names']) ? $parameters['month_names'] : false; if (!$parameters['month_names']) { $parameters['month_names'] = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); } $timestamp = time(); $steps = array('hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2592000, 'year' => 31536000); $starttitle = ''; $endtitle = ''; switch ($parameters['interval']) { case 'hour': $starthour = $hour = date('H', $parameters['start']); $endhour = date('H', $parameters['end']); $starttitle .= $starthour . ':00h '; $endtitle .= $endhour . ':59h '; case 'day': $startday = $day = date('d', $parameters['start']); $endday = date('d', $parameters['end']); $starttitle .= $startday . '. '; $endtitle .= $endday . '. '; case 'week': $week = date('W', $parameters['start']) + 2; case 'month': $startmonth = $month = date('m', $parameters['start']); $endmonth = date('m', $parameters['end']); $starttitle .= $parameters['month_names'][$startmonth - 1] . ' '; $endtitle .= $parameters['month_names'][$endmonth - 1] . ' '; case 'year': $startyear = $year = date('Y', $parameters['start']); $endyear = date('Y', $parameters['end']); $starttitle .= $startyear; $endtitle .= $endyear; } $title = $starttitle . ' - ' . $endtitle . ' in ' . $parameters['interval'] . "s."; $disp = true; $correct = 0; if ($parameters['interval'] == 'week') { $correct = 86400; } for ($start = $parameters['start']; $start < $parameters['end']; $start += $steps[$parameters['interval']]) { if ($parameters['interval'] == 'month') { $steps['month'] = $steps['day'] * date('t', $_start); } $end = $start + $steps[$parameters['interval']] - 1; if ($start <= $timestamp) { $apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start + $correct, 'end' => $end + $correct, 'constraints' => $parameters['constraints'], 'interval' => ''); for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters)); } } else { for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = 0; } } switch ($parameters['interval']) { case 'hour': $x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00'; $disp = !$disp; $hour++; break; case 'week': $x_label[] = date('W', mktime(0, 0, 0, 1, ($week - 2) * 7, $startyear)); $week++; break; case 'day': $x_label[] = date('d', mktime(0, 0, 0, $startmonth, $day, $startyear)); $day++; break; case 'month': $x_label[] = date('m', mktime(0, 0, 0, $month, 1, $startyear)); $month++; break; case 'year': $x_label[] = date('Y', mktime(0, 0, 0, 1, 1, $year)); $year++; break; } } if ($y == null) { $apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start, 'end' => $end, 'constraints' => $parameters['constraints']); for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters)); } $x_label[] = ''; $title = "Total"; } if ($parameters['interval'] == 'hour') { $angle = 50; } else { $angle = 0; } $x_label = $this->clearLabels($x_label, $parameters); $graph = new Graph($parameters['width'], $parameters['height'], 'auto'); $graph->img->SetMargin(40, 10, 20, 10); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); $graph->SetFrame(0); $graph->xgrid->Show(); for ($j = 0; $j < count($parameters["what"]); $j++) { $plot[$j] = new BarPlot($y[$j]); $plot[$j]->SetFillColor($parameters["whatcolors"][$j]); $plot[$j]->SetShadow(); $plot[$j]->SetWeight(0); } $gbarplot = new GroupBarPlot($plot); $gbarplot->SetWidth(0.6); $graph->add($gbarplot); $graph->xaxis->SetTickLabels($x_label); if ($c["usettf"]) { $graph->xaxis->SetLabelAngle($angle); } if ($c["usettf"]) { $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->yaxis->SetColor('black'); if ($c["usettf"]) { $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->title->Set($title); if ($c["usettf"]) { $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->img->SetAntiAliasing("white"); $graph->Stroke(); }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $lang, $c; $parameters['result_format'] = 'separate_result_arrays'; // hour or weeday analysis $apc = "weekdays"; if ($parameters['api_call'] == "nxhours") { $apc = "hours"; } $apicall = array('api_call' => $apc, 'what' => $parameters["what"], 'start' => $parameters["start"], 'end' => $parameters["end"]); $queryValues = phpOpenTracker::get($apicall); for ($i = 0; $i < count($queryValues); $i++) { $y[$i] = $queryValues[$i]["value"]; } $title = 'Analyse '; switch ($parameters['what']) { case 'visits': $title .= 'Visits'; break; case 'pi': $title .= 'Page Impressions'; break; case 'avg_clickstream': $title .= 'Average Clickstream'; break; case 'avg_time': $title .= 'Average Online Time'; break; } if ($apc == "hours") { for ($i = 0; $i < 24; $i++) { $x_label[$i] = sprintf("%02d", $i); } $angle = 50; } else { $x_label = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); $angle = 30; } $graph = new Graph($parameters['width'], $parameters['height'], 'auto'); $graph->img->SetMargin(40, 10, 20, 50); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); $graph->SetFrame(0); $graph->xgrid->Show(); $plot[0] = new BarPlot($y); $plot[0]->SetFillColor(__RED); $plot[0]->SetShadow(); $plot[0]->SetWeight(0); $gbarplot = new GroupBarPlot($plot); $gbarplot->SetWidth(0.6); $graph->add($gbarplot); $graph->xaxis->SetTickLabels($x_label); if ($c["usettf"]) { $graph->xaxis->SetLabelAngle($angle); } if ($c["usettf"]) { $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->yaxis->SetColor('black'); if ($c["usettf"]) { $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->title->Set($title); if ($c["usettf"]) { $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->img->SetAntiAliasing("white"); $graph->Stroke(); }
/** * 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(); }
public function draw($format = false) { /* Make sure we have GD support. */ if (!function_exists('imagecreatefromjpeg')) { die; } if ($format === false) { $format = IMG_JPEG; } $graph = new Graph($this->width, $this->height); $graph->setFormat($format); $graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4)); $graph->shadow->setSize(6); $graph->title->set($this->title); $graph->title->setFont(new Tuffy(48)); $graph->title->setColor(new Color(0x0, 0x0, 0x8b)); $graph->border->setColor(new Color(187, 187, 187, 15)); $plot = new BarPlotPipeline($this->xValues, 1, 1, 0, $this->totalValue, false); $plot->setPadding(40, 40, 15, 45); $plot->setBarColor(new DarkGreen()); $plot->barBorder->hide(true); $plot->arrayBarBackground = $this->colorArray; $plot->xAxis->setLabelText($this->xLabels); $plot->xAxis->label->setFont(new Tuffy(24)); $plot->yAxis->label->setFont(new Tuffy(18)); $graph->add($plot); $graph->draw(); die; }
/** * Формирование графика. * * Функция формирует, а затем записывает в файл ($File) изображение графика по * переданным пользователем данным($Lines). Данная функция может рисовать как одиночные, * так и многолинейные графики.Исходными данными является массив, элементы которого также * является массивами исходных данных для соответствующих графиков (данная структура * сохраняется и для одиночных графиков!). Цвет каждой линии передается в массиве * $Colors, ключи которого совпадают с ключами массива исходных данных. Цвет задается * шестнадцатиричным кодом цвета (например, 0x000000 для черного цвета). * * @param string <заголовок диаграммы> * @param string <полный путь с именем файла-результата> * @param array <исходные данные> * @param array <подписи к оси Ox> * @param array <цвета линий> */ function Artichow_Line($Name, $File, $Lines, $Labels, $Colors) { #----------------------------------------------------------------------------- $Graph = new Graph(1000, 300); $Graph->setDriver('gd'); $Graph->setAntiAliasing(TRUE); #----------------------------------------------------------------------------- $Graph->title->set($Name); $Graph->title->setFont(new Tuffy(15)); $Graph->title->move(0, -5); #----------------------------------------------------------------------------- if (Count($Lines) > 1) { #--------------------------------------------------------------------------- $Group = new PlotGroup(); $Group->setPadding(40, 40); $Group->setBackgroundColor(new Color(240, 240, 240)); } #----------------------------------------------------------------------------- $IsSetLabel = FALSE; #----------------------------------------------------------------------------- foreach ($Lines as $LineID => $Line) { #--------------------------------------------------------------------------- $Plot = new LinePlot($Line); $Color = Color_RGB_Explode($Colors[$LineID]); $Plot->setColor(new Color($Color['R'], $Color['G'], $Color['B'])); $Plot->setThickness(1); $Plot->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240), new Color(255, 255, 255), 0)); $Plot->setFillGradient(new LinearGradient(new LightOrange(10), new VeryLightOrange(90), 90)); $Plot->setPadding(50, 50, 50, 50); #--------------------------------------------------------------------------- $Plot->mark->setType(Mark::CIRCLE); $Plot->mark->setSize(5); #--------------------------------------------------------------------------- $Plot->label->set($Line); $Plot->label->move(0, -15); $Plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0)); $Plot->label->border->setColor(new Color(20, 20, 20, 20)); $Plot->label->setPadding(2, 2, 2, 2); #--------------------------------------------------------------------------- if (Count($Lines) < 2) { #------------------------------------------------------------------------- $Plot->xAxis->setLabelText($Labels); $Plot->yAxis->setLabelPrecision(1); } else { #------------------------------------------------------------------------- if (!$IsSetLabel) { #----------------------------------------------------------------------- $Plot->setXAxis(Plot::BOTTOM); $IsSetLabel = TRUE; } } #--------------------------------------------------------------------------- if (Count($Lines) > 1) { $Group->add($Plot); } #--------------------------------------------------------------------------- if (Count($Lines) > 1) { #------------------------------------------------------------------------- $Graph->add($Group); #------------------------------------------------------------------------- $Group->axis->bottom->setTickStyle(0); $Group->axis->bottom->setLabelText($Labels); } else { $Graph->add($Plot); } } #----------------------------------------------------------------------------- $Graph->draw($File); #----------------------------------------------------------------------------- return TRUE; }
function dis_chart_bar_multiple($chart) { global $chart_colors; $title = $chart["title"]; $xlabels = $chart["xlabels"]; $values = $chart["plots"]["values"]; $labels = $chart["plots"]["labels"]; $legends = $chart["plots"]["legends"]; $new_bar = $chart["plots"]["new_bar"]; $graph = new Graph(600, 250); $graph->setAntiAliasing(TRUE); $graph->setBackgroundColor(new Color(240, 240, 240)); $group = new PlotGroup; $group->grid->hideVertical(); $group->setPadding(45, 22 ,30, 40); $group->setSpace(3, 3, NULL, NULL); $group->legend->setAlign(NULL, LEGEND_TOP); $group->legend->setPosition(1,0); // X axis Labels infos $xlabel = new Label($xlabels); $group->axis->bottom->setlabelText($xlabels); // Title infos if ($title != "") { $graph->title->set("$title"); } $num = 0; $nb_bars = array_sum($new_bar); $num_bar = 0; // $num_plot is the plot number // $num_bar is the bar number (1 bar can cumul more than one plot) foreach ($values as $num_plot => $plot_values) { // Chart infos : colors, size, shadow if ($new_bar[$num_plot] == 1) { $num_bar++; } $plot = new BarPlot($plot_values, $num_bar, $nb_bars); $plot->setBarColor(new Color($chart_colors[$num_plot][0], $chart_colors[$num_plot][1], $chart_colors[$num_plot][2])); $plot->setBarSize(0.6); if ($new_bar[$num_plot] == 1) { $plot->barShadow->setSize(2); $plot->barShadow->smooth(TRUE); // Labels infos $label = new Label($labels[$num_plot]); $label->setFont(new Tuffy(8)); $label->setAlign(NULL, LABEL_TOP); $plot->label = $label; } $group->add($plot); $group->legend->add($plot, utf8_decode($legends[$num_plot]), LEGEND_BACKGROUND); } $graph->add($group); $graph->draw(); }
/** * 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(); }
$plot = new ScatterPlot(array_values($val_ytd), array_values($xkeys)); $plot->link(TRUE, make_color('ytd_color', '40FFFF')); $plot->mark->setSize(make_num('ytd_mark', 10)); $plot->mark->setFill(make_color('ytd_markcolor', 'F0F0F0')); $plot->setThickness(make_num('ytd_thick', 5)); $plot->setYAxis(PLOT_LEFT); $plot->setYMin($min); $plot->setYMax($max); $grp->add($plot); } $grp->axis->bottom->setLabelText(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')); $grp->axis->left->label->setCallbackFunction('FmtAmount'); set_font($grp->axis->bottom->label, 'x_font'); set_font($grp->axis->left->label, 'y_font'); set_font($grp->axis->right->label, 'y_font'); $graph->border->hide(); $grp->setBackgroundColor(make_color('bg_color', 'FFFFFF')); $grp->grid->setBackgroundColor(make_color('bg_plot_color', 'FFFFFF')); $graph->add($grp); $graph->draw(); // # Transpose array ($foo['baz']['bar'] --> $foo['bar']['baz']) function a_t($array) { $r = array(); foreach ($array as $k1 => $ia) { foreach ($ia as $k2 => $v) { $r[$k2][$k1] = $v; } } return $r; }
$plot = new LinePlot($x); $plot->setColor(new Orange()); $plot->setFillColor(new LightOrange(80)); $plot->mark->setType(MARK_CIRCLE); $plot->mark->setFill(new MidRed()); $plot->mark->setSize(6); $group->legend->add($plot, "John", LEGEND_MARK); $group->add($plot); $x = array(NULL, NULL, NULL, 10, 12, 14, 18, 26, 42); $plot = new LinePlot($x); $plot->setColor(new Color(120, 120, 30, 10)); $plot->setFillColor(new Color(120, 120, 60, 90)); $plot->mark->setType(MARK_SQUARE); $plot->mark->setFill(new DarkGreen()); $plot->mark->setSize(5); $group->add($plot); function setYear($value) { return $value + 2000; } $group->axis->bottom->label->setCallbackFunction('setYear'); function setK($value) { return round($value) . 'K'; } $group->axis->left->label->setCallbackFunction('setK'); $group->legend->add($plot, "George", LEGEND_MARK); $group->legend->setPosition(0.45, 0.25); $group->legend->shadow->smooth(TRUE); $graph->add($group); $graph->draw();
/** * Add a triple to the current graph, and keep count of the number of triples * @ignore */ protected function addTriple($resource, $property, $value) { $count = $this->graph->add($resource, $property, $value); $this->tripleCount += $count; return $count; }
function CreeGraphClassementZoom($fichier) { // Initialement, ces variables étaient passés dans la session // $G_listeJeux=$_SESSION['G_listeJeuxZoom']; // $G_listeJoueurs=$_SESSION['G_listeJoueursZoom']; // $G_listeResultats=$_SESSION['G_listeResultatsZoom']; // $G_MesCouleurs=$_SESSION['G_mesCouleurs']; global $G_ListeJeuxZoom; global $G_MesCouleurs; global $G_ListeResultatsMoyensZoom; global $G_ListeJoueurs; // Le niveau de transparence est définit à 95% // Ici, le graphique mesurera 620 x 700 pixels. $graph = new Graph(620, 700); // L'anti-aliasing permet d'afficher des courbes plus naturelles, // mais cette option consomme beaucoup de ressources sur le serveur. $graph->setAntiAliasing(TRUE); // Titre du graphe ! $graph->title->set("Zoom sur les quatre dernières moyennes"); // L'objet group permet de gérer plusieurs courbes sur un même grpahiques $group = new PlotGroup(); // Le style des lignes des courbes est dashed $group->grid->setType(LINE_DASHED); // La marge gauche est fixée à 40px du bord, droite à 20, haut à 40px et basse à 120px $group->setPadding(40, 20, 40, 120); // Le titre sur les absisses est : % Réussite $group->axis->left->title->set("% Reussite"); $group->setYAxisZero(false); // Les libellés sur les absisses sont inclinés de 45% $group->axis->bottom->label->setAngle(45); // Affiche 10 marques entre 2 marques majeures $group->axis->left->setNumberByTick('minor', 'major', 10); // Titre des ordonnées //$group->axis->bottom->title->set("Journées"); // La légende est affiché en bas du graphe $group->legend->setModel(LEGEND_MODEL_BOTTOM); // Position de la légénde par rapport au graphe $group->legend->setPosition(NULL, 0.9); // Nb de colonnes $group->legend->setRows(2); //$group->legend->shadow->hide(); // On créé autant de courbes qu'il y a de joueurs ! for ($j = 0; $j < sizeof($G_ListeJoueurs); $j++) { // Recherche des résultats du joueur $j $G_ResultatJoueur = array(); for ($k = 0; $k < sizeof($G_ListeJeuxZoom); $k++) { if (isset($G_ListeResultatsMoyensZoom[$k][$j])) { $G_ResultatJoueur[$k] = $G_ListeResultatsMoyensZoom[$k][$j]; } else { $G_ResultatJoueur[$k] = null; } } // Création d'une courbe pour ce joueur $plot = new LinePlot($G_ResultatJoueur); $plot->setColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2])); $plot->setFillColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2], NIVEAU_TRANSPARENCE)); $plot->mark->setType(MARK_CIRCLE); if ($j % 3 == 0) { $plot->mark->setType(MARK_TRIANGLE); } if ($j % 4 == 0) { $plot->mark->setType(MARK_CROSS); } $plot->mark->setFill(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2])); $plot->mark->setSize(7); $plot->yAxis->setLabelNumber(0.5); // $plot->xAxis->label->setAngle(45); $plot->setPadding(10, 10, 10, 10); // Ajoute d'une légende pour cette courbe et ce joueur $group->legend->add($plot, $G_ListeJoueurs[$j], LEGEND_MARK); // Ajoute cette courbe au group $group->add($plot); } // Fonction qui retourne les Abscisses function setAbscisseZoom($value) { global $G_ListeJeuxZoom; return $G_ListeJeuxZoom[$value]; } $group->axis->bottom->label->setCallbackFunction('setAbscisseZoom'); // Fonction qui retourne les Ordonnés function setOrdonneZoom($value) { return round($value); } $group->axis->left->label->setCallbackFunction('setOrdonneZoom'); // Ajout de ce groupe au graphique $graph->add($group); $graph->draw($fichier); }
if ($z == 2) { $omimai = " 熊本地震の被災地の皆様に、心よりお見舞い申し上げます。\n"; } elseif ($z == 1) { $omimai = "東日本大震災の被災地の皆様に、心よりお見舞い申し上げます。\n"; } elseif ($z == 0) { $omimai = "鳥取県中部地震の被災地の皆様に、心よりお見舞い申し上げます。\n"; } $omimai .= " 一日も早く、復興が出来ますように、お祈り申し上げます。\n"; $omimai .= " " . $data_time . "更新"; $graph->xaxis->title->Set($omimai); $graph->xaxis->title->SetFont(FF_GOTHIC, FS_NORMAL, 10); $graph->xaxis->title->SetMargin(-585); $graph->Set90AndMargin(312, 89, 90, 90); $graph->SetBackgroundGradient('white', 'green:1.5', GRAD_HOR, BGRAD_PLOT); $txt = new Text($data_w); $txt->SetPos(686, -16); $data_XXX = $xml->pref[10]->time_x; $url = "http://s-proj.com/utils/checkHoliday.php?kind=h&date=" . $data_XXX; $holiday_status = file_get_contents($url); if ($holiday_status == "holiday") { $txt->SetColor("#FF0000"); } else { $txt->SetColor("#000000"); } if ($data_w == "土") { $txt->SetColor("#0000FF"); } $txt->SetFont(FF_GOTHIC, FS_NORMAL, 10); $graph->AddText($txt); $graph->add($bplot); $graph->Stroke();
/** * Build a graph onto disk using Artichow library * * @param string $file Image file name to use if we save onto disk * @param string $fileurl Url path to show image if saved onto disk * @return void */ private function draw_artichow($file, $fileurl) { global $artichow_defaultfont; dol_syslog(get_class($this) . "::draw_artichow this->type=" . join(',', $this->type)); if (!defined('SHADOW_RIGHT_TOP')) { define('SHADOW_RIGHT_TOP', 3); } if (!defined('LEGEND_BACKGROUND')) { define('LEGEND_BACKGROUND', 2); } if (!defined('LEGEND_LINE')) { define('LEGEND_LINE', 1); } // Create graph $classname = ''; if (!isset($this->type[0]) || $this->type[0] == 'bars') { $classname = 'BarPlot'; } else { if ($this->type[0] == 'lines') { $classname = 'LinePlot'; } else { $classname = 'TypeUnknown'; } } include_once ARTICHOW_PATH . $classname . '.class.php'; // Definition de couleurs $bgcolor = new Color($this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]); $bgcolorgrid = new Color($this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]); $colortrans = new Color(0, 0, 0, 100); $colorsemitrans = new Color(255, 255, 255, 60); $colorgradient = new LinearGradient(new Color(235, 235, 235), new Color(255, 255, 255), 0); $colorwhite = new Color(255, 255, 255); // Graph $graph = new Graph($this->width, $this->height); $graph->border->hide(); $graph->setAntiAliasing(true); if (isset($this->title)) { $graph->title->set($this->title); //print $artichow_defaultfont;exit; $graph->title->setFont(new $artichow_defaultfont(10)); } if (is_array($this->bgcolor)) { $graph->setBackgroundColor($bgcolor); } else { $graph->setBackgroundGradient($colorgradient); } $group = new PlotGroup(); //$group->setSpace(5, 5, 0, 0); $paddleft = 50; $paddright = 10; $strl = dol_strlen(max(abs($this->MaxValue), abs($this->MinValue))); if ($strl > 6) { $paddleft += $strl * 4; } $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values $group->legend->setSpace(0); $group->legend->setPadding(2, 2, 2, 2); $group->legend->setPosition(NULL, 0.1); $group->legend->setBackgroundColor($colorsemitrans); if (is_array($this->bgcolorgrid)) { $group->grid->setBackgroundColor($bgcolorgrid); } else { $group->grid->setBackgroundColor($colortrans); } if ($this->hideXGrid) { $group->grid->hideVertical(true); } if ($this->hideYGrid) { $group->grid->hideHorizontal(true); } // On boucle sur chaque lot de donnees $legends = array(); $i = 0; $nblot = count($this->data[0]) - 1; while ($i < $nblot) { $x = 0; $values = array(); foreach ($this->data as $key => $valarray) { $legends[$x] = $valarray[0]; $values[$x] = $valarray[$i + 1]; $x++; } // We fix unknown values to null $newvalues = array(); foreach ($values as $val) { $newvalues[] = is_numeric($val) ? $val : null; } if ($this->type[0] == 'bars') { //print "Lot de donnees $i<br>"; //print_r($values); //print '<br>'; $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20); $colorbis = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 50); $colorgrey = new Color(100, 100, 100); $colorborder = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); if ($this->mode == 'side') { $plot = new BarPlot($newvalues, $i + 1, $nblot); } if ($this->mode == 'depth') { $plot = new BarPlot($newvalues, 1, 1, ($nblot - $i - 1) * 5); } $plot->barBorder->setColor($colorgrey); //$plot->setBarColor($color); $plot->setBarGradient(new LinearGradient($colorbis, $color, 90)); if ($this->mode == 'side') { $plot->setBarPadding(0.1, 0.1); } if ($this->mode == 'depth') { $plot->setBarPadding(0.1, 0.4); } if ($this->mode == 'side') { $plot->setBarSpace(5); } if ($this->mode == 'depth') { $plot->setBarSpace(2); } $plot->barShadow->setSize($this->SetShading); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(160, 160, 160, 50)); $plot->barShadow->smooth(TRUE); //$plot->setSize(1, 0.96); //$plot->setCenter(0.5, 0.52); // Le mode automatique est plus efficace $plot->SetYMax($this->MaxValue); $plot->SetYMin($this->MinValue); } if ($this->type[0] == 'lines') { $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20); $colorbis = new Color(min($this->datacolor[$i][0] + 20, 255), min($this->datacolor[$i][1] + 20, 255), min($this->datacolor[$i][2] + 20, 255), 60); $colorter = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 90); $plot = new LinePlot($newvalues); //$plot->setSize(1, 0.96); //$plot->setCenter(0.5, 0.52); $plot->setColor($color); $plot->setThickness(1); // Set line background gradient $plot->setFillGradient(new LinearGradient($colorter, $colorbis, 90)); $plot->xAxis->setLabelText($legends); // Le mode automatique est plus efficace $plot->SetYMax($this->MaxValue); $plot->SetYMin($this->MinValue); //$plot->setYAxis(0); //$plot->hideLine(true); } //$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures $group->legend->setTextFont(new $artichow_defaultfont(10)); // This is to force Artichow to use awFileFontDriver to // solve a bug in Artichow with UTF8 if (count($this->Legend)) { if ($this->type[0] == 'bars') { $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND); } if ($this->type[0] == 'lines') { $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE); } } $group->add($plot); $i++; } $group->axis->bottom->setLabelText($legends); $group->axis->bottom->label->setFont(new $artichow_defaultfont(7)); //print $group->axis->bottom->getLabelNumber(); if ($this->labelInterval > 0) { $group->axis->bottom->setLabelInterval($this->labelInterval); } $graph->add($group); // Generate file $graph->draw($file); $this->_stringtoshow = '<!-- Build using ' . $this->_library . ' --><img src="' . $fileurl . '" title="' . dol_escape_htmltag($this->title ? $this->title : $this->YLabel) . '" alt="' . dol_escape_htmltag($this->title ? $this->title : $this->YLabel) . '">'; }
<?php 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();