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
|
<?php
include_once("database.php");
include "src/jpgraph.php";
include "src/jpgraph_bar.php";
include "src/jpgraph_line.php";
include "src/jpgraph_date.php" ;
try{
$stat=$DB_con->prepare("SELECT * FROM qte_acheter st, produits p, categories c
WHERE st.id_produit_com=p.id_produits AND p.cat_produits=c.id_cat AND type_cat= 'homme'" );
$stat->execute();
while ($data = $stat->fetch(PDO::FETCH_ASSOC))
{
//ECHO 'Nom Du produit : '.$data['nom_produits'].'<br>'; --> mes données sont bien récupéré
// ECHO 'Quantites Achetés : '.$data['quantites'].'<br>';
$xdata[] = $data['nom_produits'];
$ydata[] = $data['quantites'];
}
// creation du graph
// instance de la classe Graph, la variable $graphique est affecté par l'object créé
//hauteur : 350 and largeur : 250
$graph = new Graph(600,250,"auto" );
// instance de la classe LinePlot, la variable $lineplot est affectée par l'objet créé
// ce lineplot contient les points définis dans le tableau $ydonnees
$lineplot = new LinePlot($ydata);
$graph->img->SetMargin(40,40,40,50);
$graph->SetScale ("datint" );
// cette méthode définit la couleur de la ligne du lineplot
$lineplot->SetColor("blue" );
// ajoute le lineplot dans le graphique
$graph->Add($lineplot);
//affichage du graphe
$graph->Stroke();
}catch (PDOException $i){
echo "erreur ".$i->getMessage();
}
?> |
Partager