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
| include "include/mysql-connect.php"; //connexion à la base de données
include 'objet/'.$_GET['obj'].'.php';
include 'include/fonction.inc.php';
include ("jpgraph-3.5.0b1/src/jpgraph.php");
include ("jpgraph-3.5.0b1/src/jpgraph_line.php");
$datedebut=$_POST['datedebut'];
$datefin=$_POST['datefin'];
$datedebutexplode=explode('-', $datedebut);
$datefinexplode = explode('-', $datefin);
$moisdatedebut=$datedebutexplode[1];
$moisdatefin=$datefinexplode[1];
$anneedatedebut=$datedebutexplode[0];
$anneedatefin=$datefinexplode[0];
$j=0;
while($j<count($tab_donnees)){
if($tab_donnees[$j][7]=="graphoui"){
$reqAffiche="SELECT @cumul := @cumul + valeur1,valeur2,valeur3 from( select count(".$tab_donnees[$j][5].") as valeur1, month(".$tab_donnees[$j][4].") as valeur2 ,year(".$tab_donnees[$j][4].") as valeur3 from ".$tab_donnees[$j][2]." where ".$tab_donnees[$j][3]."='$id' and ".$tab_donnees[$j][4]." between '$anneedatedebut-$moisdatedebut-01' and '$anneedatefin-$moisdatefin-31' group by year(".$tab_donnees[$j][4]."),month(".$tab_donnees[$j][4].") )C JOIN (SELECT @cumul :=0)tmp ";
$resultAffiche = mysqli_query($cnx, $reqAffiche) or die ("Erreur de la requête");
while($donnees = mysqli_fetch_array($resultAffiche))
{
$Nb[]= $donnees[0];
$moisgraph[] = $donnees[1];
}
}
$j++;
}
//Initialisation du Graphique
$graph = new Graph(920,500);
$graph->SetScale("intlin");
$graph->SetMargin(80,30,40,50);
$graph->SetMarginColor('white');
$graph->SetFrame(false,'blue',3);
//On initialise le titre du graphique
$graph->title->Set("Nombre de en fonction du mois");
$graph->yaxis->SetTitleMargin(50);
//On initialise le nom de l'axe des abscisses et ses valeurs
$graph->xaxis->SetTickLabels($moisgraph);
$graph->xaxis->title->Set("Mois");
$graph->xaxis->SetTextLabelInterval(2);
$graph->xgrid->Show();
//On initialise le nom de l'axe des ordonnées et ses valeurs
$graph->yaxis->title->Set("Nombre de ");
$graph->yaxis->SetLabelAlign('right','bottom');
// Creation de la courbe et affichage
$p1 = new LinePlot($Nb);
$p1->value->SetAlign('center');
$graph->Add($p1);
$graph->Stroke(); |
Partager