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
|
require_once "../mysql.php";
include ("../_class_graph/jpgraph.php");
include ("../_class_graph/jpgraph_line.php");
$date_month = date('my', mktime(0,0,0,date('m'),date('d'),date('y')));
$sql = sprintf("SELECT distinct(date) FROM stat_article");
$result = $dbh->query($sql);
$i=0;
$tab_attclient = array();
$tab_attfourn = array();
$tab_encours = array();
$tab_vide = array();
$tab_pbresil = array();
$tab_rejete = array();
foreach($result as $row){
$day = substr($row['date'],0,2);
$tab[$i] = $day;
$date = $day.$date_month;
$sql_sum = sprintf("SELECT
SUM(att_client) as attclient,
SUM(att_fourn) as attfourn,
SUM(en_cours) as encours,
SUM(vide) as vide,
SUM(pb_resil) as pbresil,
SUM(rejete) as rejete
FROM stat_article WHERE date = '$date'");
$result_sum = $dbh->query($sql_sum);
foreach($result_sum as $row_sum){
$tab_attclient[$i] = $row_sum['attclient'];
$tab_attfourn[$i] = $row_sum['attfourn'];
$tab_encours[$i] = $row_sum['encours'];
$tab_vide[$i] = $row_sum['vide'];
$tab_pbresil[$i] = $row_sum['pbresil'];
$tab_rejete[$i] = $row_sum['rejete'];
}
$i++;
}
$count_tab = count($tab);
$datay1 = array(11,7,5,8,3,5,5,4,8,6,5,5,3,2,5,1,2,0);
$datay2 = array( 4,5,4,5,6,5,7,4,7,4,4,3,2,4,1,2,2,1);
$datay3 = array(4,5,7,10,13,15,15,22,89,26,30,34,40,43,47,55,60,62);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);
// Create the linear plots for each category
$dplot[] = new LinePLot($datay1);
$dplot[] = new LinePLot($datay2);
$dplot[] = new LinePLot($datay3);
$dplot[0]->SetFillColor("red");
$dplot[1]->SetFillColor("blue");
$dplot[2]->SetFillColor("green");
// Create the accumulated graph
$accplot = new AccLinePlot($dplot);
// Add the plot to the graph
$graph->Add($accplot);
$graph->xaxis->SetTextTickInterval(2);
$graph->title->Set("grpah");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Display the graph
$graph->Stroke(); |
Partager