Hej alle!
Jeg har problemer med at få tegnet min X akse i flg. kode;
<?
include ("inc/jpgraph.php");
include ("inc/jpgraph_bar.php");
mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("stats") or die(mysql_error());
$stat_y = mysql_query("SELECT COUNT(id) AS Antal FROM info GROUP BY
Dato ORDER BY Dato ASC") or die(mysql_error());
$array_y = mysql_fetch_array($stat_y);
$stat_x = mysql_query("SELECT DISTINCT Dato FROM info GROUP BY Dato
ORDER BY Dato ASC") or die(mysql_error());
$array_x = mysql_fetch_array($stat_x);
// New graph with a drop shadow
$graph = new Graph(600,400,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($array_x);
// Set title and subtitle
$graph->title->Set("Bla bla bla");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($array_y);
$b1->SetLegend("");
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>
I begge arrys er der 3 entry, f.eks. som flg.
array_y = 10,20,30
array_x = 2004-9-05, 2004-9-06, 2004-9-07
Den skriver 2004-9-05 korrekt og tegner søjlen op af y aksen. Den
næste skriver den bare "2" ud for og tegner intet. og nr. 3 kommer
slet ikke - nogle ideer?
/Thomas
|