1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <?php
header("Content-type: image/png");
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
include ("jpgraph/src/jpgraph_line.php");
$hostname_stat = "localhost";
$database_stat = "ocsweb";
$username_stat = "root";
$password_stat = "xxxxxx";
$statinfo = mysql_connect($hostname_stat, $username_stat, $password_stat) or die(mysql_error());
mysql_select_db($database_stat, $statinfo);
$periode="";
//C'est ici que les variable $_GET["annee"] et $_GET["mois"] n'existe pas
if (isset($_GET["annee"])) {
$periode=" and year(date)=".$_GET["annee"];
}
if (isset($_GET["mois"])) {
$periode=$periode." and month(date)=".$_GET["mois"];
}
$query_liste = "select category.name,delai,round(avg(DATEDIFF(closedate,date))) as nb from category,tracking where category=category.id ".$periode." group by category.name";
$liste = mysql_query($query_liste, $statinfo) or die(mysql_error());
$delai=array();
$avg_track=array();
$theme=array();
while($ligne= mysql_fetch_row ($liste))
{
array_push($delai,$ligne[1]);
array_push($avg_track,$ligne[2]);
array_push($theme,$ligne[0]);
}
$ydata = $avg_track;
$ydata2 = $delai;
$graph = new Graph(950,650,'auto');
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetMargin(30,1,20,5);
$graph->SetBox();
$graph->SetFrame(false);
$graph->tabtitle->Set('Toutes les données');
$graph->tabtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->xaxis->title->Set("Thèmes");
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
$graph->xaxis->SetTickLabels($theme);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(45);
$graph->xaxis->SetLabelMargin(0);
$graph->img->SetMargin(40,140,40,140);
$bplot = new BarPlot($ydata);
$bplot->SetWidth(0.6);
$fcol='#4400D0';
$tcol='#FFFFFF';
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
$bplot->SetWeight(0);
$graph->Add($bplot);
$lplot = new LinePlot($ydata2);
$lplot->SetFillColor('skyblue@0.5');
$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(6);
$graph->Add($lplot);
$graph->Stroke();
?> |
Partager