require_once($_SERVER['DOCUMENT_ROOT']."/jpgraph/src/nclude_path_inc.php"); include ($_SERVER['DOCUMENT_ROOT']."/jpgraph/src/jpgraph.php"); include ($_SERVER['DOCUMENT_ROOT']."/jpgraph/src/jpgraph_bar.php");
ça affiche rien mais plutôt un texte disant :
l'image<<http://localhost/DVG/index.php?page=histo>>ne peut etre affiché car elle contient des erreurs
$bplot = new BarPlot($tableauNombreVentes);
$barplot = new BarPlot($ydata,$xdata)
//save to file $fileName = "/tmp/graph.png"; $graph->img->Stream($fileName);
$graph->Stroke($fileName); echo "<img src='".$fileName."' />";
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
$tableauAnnees = array();
$tableauNombreVentes = array();
<?php
//require_once("../jpgraph/src/include_path_inc.php");
include ("../jpgraph/src/jpgraph.php");
include ("../jpgraph/src/jpgraph_bar.php");
$tableauAnnees = array();
$tableauNombreVentes = array();
$q = mysql_query(" SELECT sexeV , COUNT(matricule) AS NBR_VENTES FROM victime GROUP BY sexeV") or die(mysql_error());
while ($row = mysql_fetch_array($q)) {
$tableauAnnees[] = 'sexe ' . $row['sexeV'];
$tableauNombreVentes[] = $row['NBR_VENTES'];
}
// *******************
// Création du graphique
// *******************
// Construction du conteneur
// Spécification largeur et hauteur
$graph = new Graph(400,250);
// Réprésentation linéaire
$graph->SetScale("textlin");
// Ajouter une ombre au conteneur
$graph->SetShadow();
// Fixer les marges
$graph->img->SetMargin(40,30,25,40);
// Création du graphique histogramme
$bplot = new BarPlot($tableauNombreVentes);
// Spécification des couleurs des barres
$bplot->SetFillColor(array('red', 'green', 'blue'));
// Une ombre pour chaque barre
$bplot->SetShadow();
// Afficher les valeurs pour chaque barre
$bplot->value->Show();
// Fixer l'aspect de la police
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
// Modifier le rendu de chaque valeur
$bplot->value->SetFormat('%d sexe');
// Ajouter les barres au conteneur
$graph->Add($bplot);
// Le titre
$graph->title->Set("Graphique 'HISTOGRAMME' : sexe");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Titre pour l'axe horizontal(axe x) et vertical (axe y)
$graph->xaxis->title->Set("sexe");
$graph->yaxis->title->Set("Nombre de sexe");
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Légende pour l'axe horizontal
$graph->xaxis->SetTickLabels($tableauAnnees);
// Afficher le graphique
$graph->Stroke();
?>
$fileName = $_SERVER['DOCUMENT_ROOT']."/tmp/graph.png";