jpgraph xaxis rækkefølge
Jeg sidder og leger med JPgraph.Nedenstående script giver mig denne graf:http://www.dytti.dk/fiskelog/jpgraph/php.php
Nu er spørgsmålet: Hvordan får jeg månederne til at stå i den rigtige rækkefølge?
Altså fra Januar til december.
<?php // content="text/plain; charset=utf-8"
include("../login/login/include/session.php");
include '../global/config.php';
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Kunne ikke forbinde til server: ' . mysql_error());
}
//vælg database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Kunne ikke vælge database");
}
require_once ("jpgraph.php");
require_once ('jpgraph_bar.php');
$SQL = "SELECT sum(antalfisk), month FROM fangst_log group by month";
$RESULT = mysql_query($SQL);
if ($myrow=mysql_fetch_array($RESULT))
{
while( $row = mysql_fetch_array( $RESULT ))
{
$fisk[] = $row['sum(antalfisk)'];
$month[] = $row['month'];
}
}
// We need some data
$datay=$fisk;
$datax=$month;
// Setup the graph.
$graph = new Graph(400,240);
$graph->img->SetMargin(60,20,35,75);
$graph->SetScale("textlin");
$graph->SetMarginColor("lightblue:1.1");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Antal fanget pr måned");
$graph->title->SetMargin(8);
$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy:0.9","navy:1.85",GRAD_LEFT_REFLECTION);
// Set color for the frame of each bar
$bplot->SetColor("white");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
?>
