Probleme d'abscisse pour JPGRAPH
Posté : 09 nov. 2005, 14:47
Bonjour a tous, voila mon petit souci :
j'utilise JpGrapH pour créer des graphique (logique jusque la), mais le problème est que je veux changer les valeurs en abscisse.
Par défault il me met 1, 2, 3, 4, etc ...
J'ai dans une base de donnée des dates. Et donc je voudrai mettre ces dates en abscisses.
Pouvez vous m'aidez ?
Voici mon code, meme si cela ne vous servira pas a grad chose.
j'utilise JpGrapH pour créer des graphique (logique jusque la), mais le problème est que je veux changer les valeurs en abscisse.
Par défault il me met 1, 2, 3, 4, etc ...
J'ai dans une base de donnée des dates. Et donc je voudrai mettre ces dates en abscisses.
Pouvez vous m'aidez ?
Voici mon code, meme si cela ne vous servira pas a grad chose.
<? require_once("./Connections/graph.php"); ?>
<?
$type = $_POST['select'];
$sql = "SELECT ValOrd1 FROM graph.test WHERE TypeGraph = 'STANDARD'";
$result = mysql_query($sql);
$tab1 = array();
while ($donnees = mysql_fetch_row($result)) {
$tab1[]=$donnees[0];
$data1y=$tab1;
}
$sql = "SELECT ValOrd2 FROM graph.test WHERE TypeGraph = 'STANDARD'";
$result = mysql_query($sql);
$tab2 = array();
while ($donnees = mysql_fetch_row($result)) {
$tab2[]=$donnees[0];
$data2y=$tab2;
}
$sql = "SELECT ValOrd3 FROM graph.test WHERE TypeGraph = 'STANDARD'";
$result = mysql_query($sql);
$tab3 = array();
while ($donnees = mysql_fetch_row($result)) {
$tab3[]=$donnees[0];
$data3y=$tab3;
}
include ("./include/jpgraph.php");
include ("./include/jpgraph_bar.php");
// Create the graph. These two calls are always required
$graph = new Graph(310,200,"auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$b3plot = new BarPlot($data3y);
$b3plot->SetFillColor("green");
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->Set("Example 21");
$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();
?>
Merci d'avance ...