Example #1
0
 /**
  * 横柱图
  * 
  */
 function createhorizoncolumnar($title, $subtitle, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
 {
     vendor("Jpgraph.jpgraph");
     vendor("Jpgraph.jpgraph_bar");
     $datay = $data;
     $datax = $legend;
     //编码转化
     foreach ($datax as $k => $v) {
         $datax[$k] = iconv('utf-8', 'gb2312', $v);
     }
     // Size of graph
     $count = count($datay);
     $addheight = 0;
     if ($count > 10) {
         $addheight = ($count - 10) * 20;
     }
     $height = $height + $addheight;
     // Set the basic parameters of the graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin");
     // No frame around the image
     $graph->SetFrame(false);
     $graph->SetFrame(false, '#ffffff', 0);
     //去掉周围的边框
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin(70, 10, 50, 30);
     // Set white margin color
     $graph->SetMarginColor('white');
     // Use a box around the plot area
     $graph->SetBox();
     // Use a gradient to fill the plot area
     $graph->SetBackgroundGradient('white', 'white', GRAD_HOR, BGRAD_PLOT);
     // Setup title
     $graph->title->Set(iconv('utf-8', 'gb2312', "{$title}"));
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
     $graph->subtitle->Set("(" . iconv('utf-8', 'gb2312', $subtitle) . ")");
     $graph->subtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Setup X-axis
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     // We don't want to display Y-axis
     $graph->yaxis->Hide();
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     //$bplot->SetShadow();
     //You can change the width of the bars if you like
     //$bplot->SetWidth(0.5);
     // Set gradient fill for bars
     $bplot->SetFillGradient('blue', '#0080C0', GRAD_HOR);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7);
     $bplot->value->SetAlign('left', 'center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%.0f');
     //$bplot->SetValuePos('max');
     // Add the bar to the graph
     $graph->Add($bplot);
     // Add some explanation text
     $txt = new Text('');
     $txt->SetPos(130, 399, 'center', 'bottom');
     $txt->SetFont(FF_COMIC, FS_NORMAL, 8);
     $graph->Add($txt);
     // .. and stroke the graph
     $graph->Stroke();
 }
Example #2
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay = array(20, 10, 35, 5, 17, 35, 22);
// Setup the graph
$graph = new Graph(400, 200);
$graph->SetMargin(40, 40, 20, 30);
$graph->SetScale("intlin");
$graph->SetBox();
$graph->SetMarginColor('darkgreen@0.8');
// Setup a background gradient image
$graph->SetBackgroundGradient('darkred', 'yellow', GRAD_HOR, BGRAD_PLOT);
$graph->title->Set('Gradient filled line plot ex2');
$graph->yscale->SetAutoMin(0);
// Create the line
$p1 = new LinePlot($datay);
$p1->SetFillGradient('white', 'darkgreen');
$p1->SetStepStyle();
$graph->Add($p1);
// Output line
$graph->Stroke();
?>


Example #3
0
// Size of graph
$width = 300;
$height = 400;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale("textlin");
// No frame around the image
$graph->SetFrame(false);
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(100, 20, 50, 30);
// Set white margin color
$graph->SetMarginColor('white');
// Use a box around the plot area
$graph->SetBox();
// Use a gradient to fill the plot area
$graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
// Setup title
$graph->title->Set("Graphic card performance");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 11);
$graph->subtitle->Set("(Non optimized)");
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 8);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
// We don't want to display Y-axis
Example #4
0
    $graph->Stroke();
} else {
    $graph = new Graph(750, 800);
    $graph->SetMargin(60, 40, 45, 90);
    //droit,gauche,haut,bas
    $graph->SetMarginColor('white');
    //$graph->SetScale("linlin");
    $graph->SetScale("textlin");
    $graph->yaxis->scale->SetGrace(1, 1);
    // Hide the frame around the graph
    $graph->SetFrame(false);
    // Setup title
    $graph->title->Set("Graphic");
    //$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
    // Note: requires jpgraph 1.12p or higher
    $graph->SetBackgroundGradient('#FFFFFF', '#CDDEFF:0.8', GRAD_HOR, BGRAD_PLOT);
    $graph->tabtitle->Set("{$fromstatsmonth_sday}-{$fromstatsday_sday} Hourly Graph - FROM {$hourinterval} to {$hourintervalplus} - NBCALLS {$nbcall} - " . "MAX LOAD = {$maxload}");
    $graph->tabtitle->SetWidth(TABTITLE_WIDTHFULL);
    //$graph->yaxis->Hide();
    // Enable X and Y Grid
    //$graph->xgrid->Show();
    $graph->xgrid->SetColor('gray@0.5');
    $graph->ygrid->SetColor('gray@0.5');
    //$graph->yaxis->HideZeroLabel();
    $graph->xaxis->HideZeroLabel();
    $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#CDDEFF@0.5');
    $graph->xaxis->SetTickLabels($datax);
    $graph->xaxis->SetLabelAngle(90);
    $graph->yaxis->HideFirstLastLabel();
    //$graph->yaxis->HideLine();
    $graph->yaxis->HideTicks();
Example #5
0
require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
$datay = array(0, 25, 12, 47, 27, 27, 0);
// Setup the graph
$graph = new Graph(350, 250);
$graph->SetScale("intlin", 0, $aYMax = 50);
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->SetMargin(40, 40, 50, 40);
$graph->title->Set('Inverted Y-axis');
$graph->SetBox(false);
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// For background to be gradient, setfill is needed first.
$graph->ygrid->SetFill(true, '#FFFFFF@0.5', '#FFFFFF@0.5');
$graph->SetBackgroundGradient('#FFFFFF', '#00FF7F', GRAD_HOR, BGRAD_PLOT);
$graph->xaxis->SetTickLabels(array('G', 'F', 'E', 'D', 'C', 'B', 'A'));
$graph->xaxis->SetLabelMargin(20);
$graph->yaxis->SetLabelMargin(20);
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->img->SetAngle(180);
// Create the line
$p1 = new LinePlot($datay);
$graph->Add($p1);
$p1->SetFillGradient('#FFFFFF', '#F0F8FF');
$p1->SetColor('#aadddd');
// Output line
$graph->Stroke();
?>

Example #6
0
// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.php";
$datay1 = array(4, 26, 12, 18, 8, 22);
$datay2 = array(12, 9, 42, 8, 20, 19);
// Setup the graph
$graph = new Graph(300, 200);
$graph->SetMarginColor('white');
$graph->SetScale("textlin", 0, 50);
$graph->SetMargin(30, 50, 30, 30);
// We must have the frame enabled to get the gradient
// However, we don't want the frame line so we set it to
// white color which makes it invisible.
$graph->SetFrame(true, 'white');
// Setup a background gradient image
$graph->SetBackgroundGradient('blue', 'navy:0.5', GRAD_HOR, BGRAD_PLOT);
// Setup the tab title
$graph->tabtitle->Set(' 3rd Division ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13);
// Setup x,Y grid
$graph->xgrid->Show();
$graph->xgrid->SetColor('gray@0.5');
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
$graph->ygrid->SetColor('gray@0.5');
// Setup color for axis and labels on axis
$graph->xaxis->SetColor('orange', 'black');
$graph->yaxis->SetColor('orange', 'black');
// Ticks on the outsid
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
// Setup the legend box colors and font
Example #7
0
}
$n = count($datax);
$xmin = $datax[0];
$xmax = $datax[$n - 1];
//
// The code to setup a very basic graph
//
$graph = new Graph(400, 200);
// We use an integer scale on the X-axis since the positions on the X axis
// are assumed to be UNI timestamps
$graph->SetScale('linlin', 0, 0, $xmin, $xmax);
$graph->title->Set('Example with manual tick labels');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->SetColor('white');
// Setup a abackground gradient
$graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN);
$graph->SetPlotGradient('black', 'darkred:0.8', 2);
// Make sure that the X-axis is always at the bottom of the scale
// (By default the X-axis is alwys positioned at Y=0 so if the scale
// doesn't happen to include 0 the axis will not be shown)
$graph->xaxis->SetPos('min');
// Now set the tic positions
$graph->xaxis->SetMajTickPositions($tickPositions, $tickLabels);
// Use Times font
$graph->xaxis->SetFont(FF_TIMES, FS_NORMAL, 11);
$graph->yaxis->SetFont(FF_TIMES, FS_NORMAL, 9);
// Set colors for axis
$graph->xaxis->SetColor('lightgray');
$graph->yaxis->SetColor('lightgray');
// Add a X-grid
$graph->xgrid->Show();
function CourbeParHeure($zoom = false)
{
    $day = $_GET["DAY"];
    if ($day == null) {
        $day = date('Y-m-d');
    }
    @mkdir($_GET["BASEPATH"], 0755, true);
    $f_name = "day-global-{$day}.png";
    if ($zoom) {
        $f_name = "day-global-{$day}-zoom.png";
    }
    $fileName = "{$_GET["BASEPATH"]}/{$f_name}";
    if (is_file($fileName)) {
        if (file_get_time_min($fileName) < 20) {
            return "{$_GET["IMGPATH"]}/{$f_name}";
        }
    }
    @unlink($fileName);
    $q = new mysql();
    $sql = "SELECT COUNT(ID) as tcount ,DATE_FORMAT(zDate,'%h') as thour \nFROM `mbx_con`  WHERE DATE_FORMAT(zDate,'%Y-%m-%d')='{$day}' GROUP BY thour ORDER BY thour";
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ydata[] = $ligne["tcount"];
        $xdata[] = $ligne["thour"];
    }
    if (count($ydata) < 2) {
        $ydata[] = 1;
        $xdata[] = date('d');
    }
    $width = 500;
    $height = 200;
    if ($zoom) {
        $width = 720;
        $height = 400;
    }
    $graph = new Graph($width, $height);
    $graph->SetScale('textlin');
    $graph->title->Set("Connexions numbers {$day}");
    $graph->title->SetColor('white');
    $graph->xaxis->title->Set('hours');
    $graph->xaxis->SetTickLabels($xdata);
    $graph->yaxis->title->Set('(connexions)');
    $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN);
    $graph->SetPlotGradient('black', 'darkred:0.8', 2);
    $graph->xaxis->SetColor('lightgray');
    $graph->yaxis->SetColor('lightgray');
    $graph->xgrid->Show();
    $lineplot = new LinePlot($ydata);
    $lineplot->SetWeight(2);
    $lineplot->SetColor('orange:0.9');
    $lineplot->SetFillColor('white@0.7');
    $lineplot->SetFillFromYMin();
    $lineplot->SetWeight(2);
    $lineplot->SetFilled(true);
    $lineplot->SetFillFromYMin(true);
    $graph->Add($lineplot);
    $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
    $graph->img->Stream($fileName);
    return "{$_GET["IMGPATH"]}/{$f_name}";
}
Example #9
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay = array(20, 10, 35, 5, 17, 35, 22);
// Setup the graph
$graph = new Graph(400, 250);
$graph->SetScale("intlin", 0, $aYMax = 50);
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->SetBox(false);
$graph->title->Set('Step Line');
$graph->ygrid->Show(true);
$graph->xgrid->Show(false);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#FFFFFF@0.5', '#FFFFFF@0.5');
$graph->SetBackgroundGradient('blue', '#55eeff', GRAD_HOR, BGRAD_PLOT);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D', 'E', 'F', 'G'));
// Create the line
$p1 = new LinePlot($datay);
$graph->Add($p1);
$p1->SetFillGradient('yellow', 'red');
$p1->SetStepStyle();
$p1->SetColor('#808000');
// Output line
$graph->Stroke();
?>


Example #10
0
function courbe_today($domain)
{
    $tpl = new templates();
    $q = new mysql();
    $dansguardian_events = "dansguardian_events_" . date('Ym');
    $sql = "SELECT COUNT( ID ) AS tcount, sitename, DATE_FORMAT( zdate, '%H' ) AS thour , DATE_FORMAT( zdate, '%Y-%m-%d' ) AS tday\nFROM {$dansguardian_events}\nWHERE sitename = '{$domain}'\nGROUP BY thour , tday\nHAVING tday = DATE_FORMAT( NOW( ) , '%Y-%m-%d' )\nORDER BY thour";
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $GLOBALS["stats-array-{$domain}"][] = "<tr>\n\t<td style='font-size:12px;font-weight:bold' nowrap>{$ligne["thour"]}:00</td>\n\t<td style='font-size:12px;font-weight:bold' nowrap>{$ligne["tcount"]} hits</td>\n\t</tr>\n\t";
        $ydata[] = $ligne["tcount"];
        $xdata[] = $ligne["hour"];
    }
    $f_name = "day-squid-{$domain}.png";
    $fileName = "ressources/logs/{$f_name}";
    if (is_file($fileName)) {
        if (file_get_time_min($fileName) < 120) {
            return $fileName;
        }
    }
    $title = "{$domain} " . $tpl->_ENGINE_parse_body('{today}');
    @unlink($fileName);
    $width = 500;
    $height = 200;
    if ($zoom) {
        $width = 720;
        $height = 400;
    }
    JpGraphError::SetImageFlag(false);
    $graph = new Graph($width, $height);
    $graph->SetScale('textlin');
    $graph->title->Set($title);
    $graph->title->SetColor('white');
    $graph->xaxis->title->Set('hours');
    $graph->xaxis->SetTickLabels($xdata);
    $graph->yaxis->title->Set('(hits number)');
    $graph->yaxis->scale->SetGrace(10);
    $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN);
    $graph->SetPlotGradient('black', 'darkred:0.8', 2);
    $graph->SetMargin(55, 20, 60, 20);
    //$graph->img->SetMargin(50,30,30,100);
    $graph->xaxis->SetColor('lightgray');
    $graph->yaxis->SetColor('lightgray');
    $graph->xgrid->Show();
    $lineplot = new LinePlot($ydata);
    $lineplot->SetWeight(2);
    $lineplot->SetColor('orange:0.9');
    $lineplot->SetFillColor('white@0.7');
    $lineplot->SetFillFromYMin();
    $lineplot->SetWeight(2);
    $lineplot->SetFilled(true);
    $lineplot->SetFillFromYMin(true);
    $graph->Add($lineplot);
    JpGraphError::SetImageFlag(false);
    try {
        $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
    } catch (JpGraphException $e) {
        // .. do necessary cleanup
        // Send back error message
        // $e->Stroke();
    }
    $graph->img->Stream($fileName);
    return $fileName;
}
Example #11
0
$graph->title->Set("\n《大手電力会社 電力使用率》");
$z = date("H") % 3;
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);
Example #12
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);
    }
}
            $prev = $col[0];
            $i++;
            $j = 0;
            for ($t = 0; $t < 40; $t++) {
                $datay[$i][$t] = 0;
            }
        }
        $datay[get_index($col[3])][$i] = $col[2];
        $datax[$i] = date("H:j", $col[0]);
        $j++;
    }
}
#echo "<pre>"; print_r($datay); echo "</pre>"; exit;
$graph = new Graph(800, 768, "auto");
$graph->SetShadow();
$graph->SetBackgroundGradient('#8e8e8e', '#e1e1e1');
// Use an integer X-scale
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Memory Leaks");
$graph->subtitle->Set("Shows the number of unfreed blocks requested by each module");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
function plotGraph($lab, $xdata, $ydata, $f)
{
    /*
    Include JpGraph in your script. Note that jpgraph.php should reside in a directory that's present in your PHP INCLUDE_PATH, otherwise specify the full path yourself.
    */
    require_once 'jpgraph/src/jpgraph.php';
    /*
    Include the module for creating line graph plots.
    */
    require_once 'jpgraph/src/jpgraph_line.php';
    // Include the module for creating line graph plots.
    //$ydata = array(6, 3, 8, 5, 15, 16, 19);
    /*
    We're not going to set the values for the X axis.
    */
    //$xdata = array(0, 1, 2, 3, 4, 5, 6);
    /*
    Let's create a Graph instance and set some variables (width, height, cache filename, cache timeout). If the last argument "inline" is true the image is streamed back to the browser, otherwise it's only created in the cache.
    */
    $graph = new Graph(800, 800, 'auto', 10, true);
    // Setting what axises to use
    $graph->SetScale('textint');
    //$graph->img->SetMargin(50,50,60,40);
    $graph->xaxis->SetTickLabels($xdata);
    /*
    Next, we need to create a LinePlot with some example parameters.
    */
    $lineplot = new LinePlot($ydata);
    // Setting the LinePlot color
    $lineplot->SetColor('black');
    // Adding LinePlot to graphic
    $graph->Add($lineplot);
    // Giving graphic a name
    $graph->title->Set('Time-series Status Graph');
    $graph->title->SetColor("white");
    /*
    If the graph is going to have labels with international characters, make sure to use a TrueType font that includes the required characters, e.g. Arial.
    */
    //$graph->title->SetFont(FF_ARIAL, FS_NORMAL);
    //$graph->xaxis->title->SetFont(FF_VERDANA, FS_ITALIC);
    //$graph->yaxis->title->SetFont(FF_TIMES, FS_BOLD);
    // Naming axises
    //$graph->xaxis->title->Set('Time');
    $graph->yaxis->title->Set($lab);
    //$graph->xaxis->title->SetColor("white");
    $graph->yaxis->title->SetColor("white");
    // Coloring axises
    $graph->xaxis->SetColor("white");
    $graph->xaxis->SetLabelAngle(50);
    $graph->yaxis->SetColor("white");
    // Setting the LinePlot width
    $lineplot->SetWeight(3);
    // To define a marker type, we denote dots as asterisks
    $lineplot->mark->SetType(MARK_FILLEDCIRCLE);
    // Showing value above each dot
    $lineplot->value->Show();
    // Filling background with a gradient
    $graph->SetBackgroundGradient('blue', 'blue');
    // Adding a shadow
    $graph->SetShadow(4);
    /* 
    Showing image in browser. If, when creating an graph object, the last parameter is false, the image would be saved in cache and not showed in browser.
    */
    $graph->Stroke($f);
}
function courbeparmois($zoom = false)
{
    $month = $_GET["MONTH"];
    @mkdir($_GET["BASEPATH"], 0755, true);
    $f_name = "day-global-{$month}.png";
    if ($zoom) {
        $f_name = "day-global-{$month}-zoom.png";
    }
    $fileName = "{$_GET["BASEPATH"]}/{$f_name}";
    if (is_file($fileName)) {
        if (file_get_time_min($fileName) < 120) {
            return "{$_GET["IMGPATH"]}/{$f_name}";
        }
    }
    @unlink($fileName);
    $q = new mysql();
    $sql = "SELECT SUM(emails) as tcount , DATE_FORMAT(DAY,'%d') as tday FROM `smtp_logs_day`  WHERE DATE_FORMAT(DAY,'%Y-%m')='{$_GET["MONTH"]}' GROUP BY tday ORDER BY tday";
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ydata[] = $ligne["tcount"];
        $xdata[] = $ligne["DAY"];
    }
    if (count($ydata) < 2) {
        $ydata[] = 1;
        $xdata[] = date('d');
    }
    $width = 500;
    $height = 200;
    if ($zoom) {
        $width = 720;
        $height = 400;
    }
    $graph = new Graph($width, $height);
    $graph->SetScale('textlin');
    $graph->title->Set("Received Mails {$_GET["MONTH"]}");
    $graph->title->SetColor('white');
    $graph->xaxis->title->Set('days');
    $graph->xaxis->SetTickLabels($xdata);
    $graph->yaxis->title->Set('(emails number)');
    $graph->yaxis->scale->SetGrace(10);
    $graph->SetBackgroundGradient('darkred:0.7', 'black', 2, BGRAD_MARGIN);
    $graph->SetPlotGradient('black', 'darkred:0.8', 2);
    $graph->SetMargin(55, 20, 60, 20);
    //$graph->img->SetMargin(50,30,30,100);
    $graph->xaxis->SetColor('lightgray');
    $graph->yaxis->SetColor('lightgray');
    $graph->xgrid->Show();
    $lineplot = new LinePlot($ydata);
    $lineplot->SetWeight(2);
    $lineplot->SetColor('orange:0.9');
    $lineplot->SetFillColor('white@0.7');
    $lineplot->SetFillFromYMin();
    $lineplot->SetWeight(2);
    $lineplot->SetFilled(true);
    $lineplot->SetFillFromYMin(true);
    $graph->Add($lineplot);
    $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
    $graph->img->Stream($fileName);
    return "{$_GET["IMGPATH"]}/{$f_name}";
}