Exemplo n.º 1
0
// Set legend box specification
$graph->legend->SetFillColor("white");
$graph->legend->SetLineWeight(2);
// Set X-axis at the minimum value of Y-axis (default will be at 0)
$graph->xaxis->SetPos("min");
// "min" will position the x-axis at the minimum value of the Y-axis
// Extend the margin for the labels on the Y-axis and reverse the direction
// of the ticks on the Y-axis
$graph->yaxis->SetLabelMargin(12);
$graph->xaxis->SetLabelMargin(6);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->xaxis->SetTickSide(SIDE_DOWN);
// Add mark graph with static lines
$line = new PlotLine(HORIZONTAL, 0, "black", 2);
$graph->AddLine($line);
// Create a new impuls type scatter plot
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_SQUARE);
$sp1->mark->SetFillColor("red");
$sp1->mark->SetWidth(3);
$sp1->SetImpuls();
$sp1->SetColor("blue");
$sp1->SetWeight(1);
$sp1->SetLegend("Non-causal signal");
$graph->Add($sp1);
// Create the envelope plot
$ep1 = new LinePlot($datayenv, $datax);
$ep1->SetStyle("dotted");
$ep1->SetLegend("Positive envelope");
$graph->Add($ep1);
$graph->Stroke();
Exemplo n.º 2
0
$lineplot2->SetLegend("4 in");
// Create the linear plot
$lineplot3 = new LinePlot($ydata3);
$lineplot3->SetColor("chocolate4");
$lineplot3->SetLegend("8 in");
$lineplot3->SetStyle("dashed");
// Create the linear plot
$lineplot4 = new LinePlot($ydata4);
$lineplot4->SetColor("blue");
$lineplot4->SetLegend("20 in");
// Create the linear plot
$lineplotA = new LinePlot($ydataA);
$lineplotA->SetColor("black");
$lineplotA->SetLegend("2m Air");
// Create the linear plot
$lineplot5 = new LinePlot($ydata5);
$lineplot5->SetColor("black");
$lineplot5->SetLegend("40 in");
$lineplot5->SetStyle("dotted");
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.1, 0.06, "right", "top");
// Add the plot to the graph
$graph->Add($lineplot1);
$graph->Add($lineplot2);
$graph->Add($lineplot3);
$graph->Add($lineplot4);
$graph->Add($lineplot5);
$graph->Add($lineplotA);
$graph->AddY2($lineplot);
// Display the graph
$graph->Stroke();
Exemplo n.º 3
0
/**
 * Un tableau contenant les moyennes des eleves pour chaque sequences
 * 
 * @param type $moyennes = array()
 */
function genererCourbe($moyennes, $rang, $codeperiode = "S")
{
    try {
        # Donnees de la courbe
        $ydata = $moyennes;
        $ydata2 = $moyennes;
        /* for ($i = 1; $i <= 6; $i++) {
           $r = rand(0, 20);
           $ydata[] = $r;
           $ydata2[] = $r;
           } */
        /** Definition des label de l'axe x */
        if ($codeperiode === "T") {
            $datax = array("TRIM1", "TRIM2", "TRIM3");
        } else {
            $datax = array("seq 1", "seq 2", "seq 3", "seq 4", "seq 5", "seq 6");
        }
        # Creation du graph
        $graph = new Graph(350, 250, 'auto');
        $graph->SetMarginColor('white');
        # Definir le max et le min des valeur X
        $graph->SetScale('textlin', 0, 20);
        #$graph->xaxis->title->Set("Séquences");
        $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        $graph->yaxis->title->Set("Moyennes");
        $graph->xaxis->SetTickLabels($datax);
        $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        if ($codeperiode === "T") {
            $graph->xaxis->SetTitle("Trimestres", "middle");
        } else {
            $graph->xaxis->SetTitle("Séquences", "middle");
        }
        $graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
        # Adjuster les margins (left, right, top, bottom)
        $graph->SetMargin(40, 5, 21, 45);
        # Box autour du plotarea
        $graph->SetBox();
        # Un cadre ou frame autour de l'image
        $graph->SetFrame(false);
        # Definir le titre tabulaire
        $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 8);
        $graph->tabtitle->Set($_SESSION['anneeacademique']);
        # Definir le titre du graphe
        $graph->title->SetFont(FF_VERDANA, FS_BOLD, 8);
        $graph->title->SetAlign("right");
        if (count($ydata) > 1) {
            $prev = $ydata[count($ydata) - 2];
            if ($prev < $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance en hausse");
            } elseif ($prev == $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance constante");
            } else {
                $graph->title->Set("Performance en baisse");
            }
        }
        # Definir les grid X et Y
        $graph->ygrid->SetFill(true, '#BBBBBB@0.9', '#FFFFFF@0.9');
        //$graph->ygrid->SetLineStyle('dashed');
        //$graph->ygrid->SetColor('gray');
        //$graph->xgrid->SetLineStyle('dashed');
        $graph->xgrid->SetColor('gray');
        $graph->xgrid->Show();
        //$graph->ygrid->Show();
        #$graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_MARGIN);
        $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
        $graph->xaxis->SetLabelAngle(0);
        # Creation d'une bar pot
        $bplot = new BarPlot($ydata);
        $bplot->SetWidth(0.9);
        $fcol = '#440000';
        $tcol = '#FF9090';
        $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
        # Set line weigth to 0 so that there are no border around each bar
        $bplot->SetWeight(0);
        # Create filled line plot
        $lplot = new LinePlot($ydata2);
        $lplot->SetFillColor('skyblue@0.5');
        $lplot->SetStyle(1);
        $lplot->SetColor('navy@0.7');
        $lplot->SetBarCenter();
        $lplot->mark->SetType(MARK_SQUARE);
        $lplot->mark->SetColor('blue@0.5');
        $lplot->mark->SetFillColor('lightblue');
        $lplot->mark->SetSize(5);
        # Afficher les moyenne au dessus des barres
        $accbarplot = new AccBarPlot(array($bplot));
        $accbarplot->value->SetFormat("%.2f");
        $accbarplot->value->Show();
        $graph->Add($accbarplot);
        $graph->SetBackgroundImageMix(50);
        # Definir un fond d'ecran pour l'image
        $background = SITE_ROOT . "public/photos/eleves/" . $rang['PHOTOEL'];
        if (!empty($rang['PHOTOEL']) && file_exists(ROOT . DS . "public" . DS . "photos" . DS . "eleves" . DS . $rang['PHOTOEL'])) {
            $graph->SetBackgroundImage($background, BGIMG_FILLPLOT);
            # $icon = new IconPlot($background, 25, 25, 0.8, 50);
        } else {
            //$graph->SetBackgroundImage(SITE_ROOT . "public/img/". LOGO, BGIMG_FILLPLOT);
            # $icon = new IconPlot(SITE_ROOT . "public/img/ipw.png", 25, 25, 0.8, 50);
        }
        # $icon->SetAnchor('right', 'bottom');
        $graph->Add($lplot);
        // Display the graph
        $filename = ROOT . DS . "public" . DS . "tmp" . DS . $rang['IDELEVE'] . ".png";
        if (file_exists($filename)) {
            unlink($filename);
        }
        $graph->Stroke($filename);
        //echo "<img src='" . SITE_ROOT . "public/tmp/emp.png' />";
    } catch (Exception $e) {
        var_dump($e);
    }
}
Exemplo n.º 4
0
<?php

include "../jpgraph.php";
include "../jpgraph_line.php";
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(350, 250, "auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(30, 90, 40, 50);
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set("Dashed lineplot");
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetLegend("Test 1");
$lineplot->SetColor("blue");
// Style can also be specified as SetStyle([1|2|3|4]) or
// SetStyle("solid"|"dotted"|"dashed"|"lobgdashed")
$lineplot->SetStyle("dashed");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Exemplo n.º 5
0
 private function templateGraph()
 {
     $sites2 = $this->getSites2();
     //		echo 'User1';
     //		var_dump($this->user1->displayUsername());
     //		if ($this->user2 !== false) {
     //			echo 'User2';
     //			var_dump($this->user2->displayUsername());
     //		}
     //		echo 'Sites';
     //		var_dump($sites2);
     //		var_dump(sprintf('%d_%d_%d', Common::getGet('y'), Common::getGet('m'), Common::getGet('d')));
     //		echo 'Start';
     //		var_dump($this->start);
     //		echo 'End';
     //		var_dump($this->end);
     //		echo 'Icons';
     //		var_dump($this->withIcons);
     //		echo 'Numbers';
     //		var_dump($this->withNumbers);
     $dir = dirname(GWF_JPGRAPH_PATH) . '/';
     require_once $dir . 'jpgraph.php';
     require_once $dir . 'jpgraph_date.php';
     require_once $dir . 'jpgraph_line.php';
     require_once $dir . 'jpgraph_plotline.php';
     $xdata = array();
     $ydata = array();
     $ylast = array();
     $maxperc = 0;
     $db = gdo_db();
     $uid1 = $this->user1->getVar('user_id');
     $uid2 = $this->user2 === false ? 0 : $this->user2->getVar('user_id');
     //		$history = GWF_TABLE_PREFIX.'wc_user_history2';
     $start = GWF_Time::getTimestamp($this->start);
     $end = GWF_Time::getTimestamp($this->end) + GWF_Time::ONE_DAY;
     $no_data = true;
     $xdata[$uid1] = array();
     $ydata[$uid1] = array();
     $ylast[$uid1] = array();
     if ($uid2 === 0) {
         $where2 = '';
     } else {
         $where2 = " OR userhist_uid={$uid2}";
         $xdata[$uid2] = array();
         $ydata[$uid2] = array();
         $ylast[$uid2] = array();
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php';
     $history = GDO::table('WC_HistoryUser2');
     $where = "(userhist_uid={$uid1}{$where2}) AND userhist_date BETWEEN {$start} AND {$end}";
     $orderby = 'userhist_date ASC';
     if (false === ($result = $history->select('userhist_uid, userhist_sid, userhist_percent, userhist_date', $where, $orderby))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     //		$query = "SELECT userhist_uid, userhist_sid, userhist_percent, userhist_date FROM $history WHERE (userhist_uid=$uid1$where2) AND userhist_date BETWEEN $start AND $end ORDER BY userhist_date ASC";
     //		if (false === ($result = $db->queryRead($query))) {
     //			return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     //		}
     //		while (false !== ($row = $db->fetchRow($result)))
     while (false !== ($row = $history->fetch($result, GDO::ARRAY_N))) {
         $siteid = $row[1];
         if (!in_array($siteid, $sites2, true)) {
             continue;
             // site not wanted in graph...
         }
         $userid = $row[0];
         $percent = $row[2] / 100;
         $time = $row[3];
         if ($percent > $maxperc) {
             $maxperc = $percent;
         }
         if (!isset($xdata[$userid][$siteid])) {
             $xdata[$userid][$siteid] = array();
             $ydata[$userid][$siteid] = array();
             $ylast[$userid][$siteid] = 0;
             //				$first[$siteid] = $percent;
             if (!$this->withZoom) {
                 $xdata[$userid][$siteid][] = $start;
                 $ydata[$userid][$siteid][] = $percent;
             }
         }
         $xdata[$userid][$siteid][] = $time;
         $ydata[$userid][$siteid][] = $percent;
         $ylast[$userid][$siteid] = $percent;
         $no_data = false;
     }
     if (!$this->withZoom) {
         foreach (array_keys($ydata[$uid1]) as $siteid) {
             $xdata[$uid1][$siteid][] = $end;
             $ydata[$uid1][$siteid][] = $ylast[$uid1][$siteid];
         }
         if (isset($ydata[$uid2])) {
             foreach (array_keys($ydata[$uid2]) as $siteid) {
                 $xdata[$uid2][$siteid][] = $end;
                 $ydata[$uid2][$siteid][] = $ylast[$uid2][$siteid];
             }
         }
     }
     //		$xdata[$siteid][] = $end;
     //		$ydata[$siteid][] = $percent;
     //		$ylast[$siteid] = $percent;
     //		foreach ($sites2 as $siteid)
     //		{
     //			$xdata[$siteid][] = $end;
     //			$ydata[$siteid][] = isset($ylast[$siteid]) ;
     //		}
     //define the graph
     $dateformat = "d.M.y";
     $datemargin = strlen(date($dateformat)) * 11;
     //		$graph = new Graph($this->module->cfgGraphWidth()*2, $this->module->cfgGraphHeight()*2);
     $graph = new Graph($this->width, $this->height);
     if ($no_data) {
         $graph->SetScale('textint', 0, 100, 0, 1);
     } else {
         $graph->SetScale('datlin', 0, 100);
         $graph->xaxis->scale->SetDateFormat($dateformat);
     }
     $graph->SetColor(array(238, 238, 238));
     $graph->SetMarginColor(array(208, 211, 237));
     $graph->title->Set($this->getGraphTitle());
     $graph->yaxis->title->Set($this->module->lang('percentage'));
     $graph->SetShadow();
     $graph->xaxis->SetLabelAngle(90);
     $graph->img->SetMargin(40, 170, 20, $datemargin);
     //		$graph->img->SetMargin(40, 140, 0, $datemargin);
     $graph->legend->Pos(0.015, 0.05, "right", "top");
     $weights = array($uid1 => 3, $uid2 => 1);
     $labeled = array();
     //make a line for each site (and user)
     foreach ($ydata as $userid => $ydata2) {
         $curr_weight = $weights[$userid];
         foreach ($ydata2 as $siteid => $data) {
             //			var_dump($data);
             if (!isset($this->sites[$siteid])) {
                 continue;
             }
             $site = $this->sites[$siteid];
             $site instanceof WC_Site;
             $lineplot = new LinePlot($data, $xdata[$userid][$siteid]);
             list($color, $style) = $this->getColorAndStyle($site);
             $lineplot->SetStyle($style);
             $lineplot->SetColor($color);
             $lineplot->SetWeight($curr_weight);
             if ($this->withNumbers) {
                 $lineplot->value->Show();
             }
             if ($this->withIcons) {
                 $path = 'dbimg/logo_gif/' . $siteid . '.gif';
                 if (is_readable($path)) {
                     $lineplot->mark->SetType(MARK_IMG, $path, 0.5);
                 }
             }
             if (!in_array($siteid, $labeled, true)) {
                 $lineplot->SetLegend($site->getVar('site_name'));
                 $labeled[] = $siteid;
             }
             $graph->Add($lineplot);
         }
     }
     //		$graph->img->SetAntiAliasing();
     if ($no_data) {
         if (count($this->sites) === 0) {
             $text = $this->module->lang('err_no_sites');
         } else {
             $text = $this->module->lang('err_graph_empty');
         }
         $txt = new Text($text);
         //			$txt->SetFont(FF_ARIAL,FS_NORMAL,18);
         $txt->SetColor("#0000ff");
         $txt->SetPos(0.45, 0.45, 'center', 'center');
         $graph->AddText($txt);
     }
     $graph->Stroke();
     die;
 }
Exemplo n.º 6
0
$graph->xaxis->SetTextLabelInterval(12);
$graph->yaxis->scale->SetGrace(10, 0);
$graph->yaxis->SetColor("blue");
$graph->y2axis->scale->SetGrace(10, 0);
$graph->y2axis->SetColor("darkgreen");
$lineCaches = new LinePlot($yDataCaches, $xDate);
$lineCaches->SetLegend(tr("graph_statistics_02"));
$lineCaches->SetColor("blue");
$lineCaches->SetStyle("solid");
$lineCaches->SetWeight(3);
$lineCaches->SetStepStyle();
$graph->Add($lineCaches);
$lineFound = new LinePlot($yDataLogs, $xDate);
$lineFound->SetLegend(tr("graph_statistics_03"));
$lineFound->SetColor("darkgreen");
$lineFound->SetStyle("solid");
$lineFound->SetWeight(2);
$lineFound->SetStepStyle();
$graph->AddY2($lineFound);
//
// Infotexte einfuegen
//
$txtStat1 = new Text(tr('graph_statistics_04') . strftime('%d-%m-%Y', time()));
$txtStat1->SetPos(55, 55);
$txtStat1->SetFont(FF_ARIAL, FS_NORMAL, 10);
$lineHeight = $txtStat1->GetFontHeight($graph->img);
$hiddenCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE (`status`=1 OR `status`=2 OR `status`=3)", 0);
$txtStat2 = new Text(tr('graph_statistics_05') . str_replace(',', '.', number_format($hiddenCaches)));
$txtStat2->SetPos(55, 55 + $lineHeight * 1.5);
$txtStat2->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat2->SetColor('blue');
Exemplo n.º 7
0
$bp1->SetFillColor("blue");
$bp1->SetLegend("Low Temp (F)");

$gbplot = new GroupBarPlot(array($bp0,$bp1));
$gbplot->SetWidth(0.9);
*/
$l1 = new LinePlot($y1);
$l1->SetColor("red");
$l1->SetWeight(2);
$l1->SetLegend("High Temp");
$l1->SetStyle('dashed');
$l2 = new LinePlot($y2);
$l2->SetColor("blue");
$l2->SetWeight(2);
$l2->SetLegend("Low Temp");
$l2->SetStyle('dashed');
$lp1 = new LinePlot($cy1);
$lp1->SetColor("red");
$lp1->SetLegend("CDF (high temp)");
$lp1->AddArea($h5, $h95, LP_AREA_NOT_FILLED, "lightred");
$lp1->AddArea($hm, $hm, LP_AREA_FILLED, "lightred");
$lp1->SetWeight(2);
$lp2 = new LinePlot($cy2);
$lp2->SetColor("blue");
$lp2->SetLegend("CDF (low temp)");
$lp2->AddArea($l5, $l95, LP_AREA_NOT_FILLED, "lightblue");
$lp2->AddArea($lm, $lm, LP_AREA_FILLED, "lightblue");
$lp2->SetWeight(2);
// Add the plot to the graph
//$graph->Add($gbplot);
$graph->AddY2($l1);