Hi all.
I am trying to build a script that uses jpGraph, I have a php script that call another srcipt that contains the code to produce bar chart.
The script that holds the code to creat the bar chart call it data from an MySQL table.
The problem I am having is that I get an error "empty input data array specified for plot. Must have at least one data point".
The code I am using is:
require_once('../../Connections/conn.php');
include ("/jpGraph/jpgraph.php");
include ("/jpGraph/jpgraph_line.php");
include ("/jpGraph/jpgraph_bar.php");
$SQL = "SELECT * FROM amember_baggagefound";
$RESULT = mysql_query($SQL);
if ($myrow=mysql_fetch_array($RESULT)) {
do {
$data[] = $myrow["f_baggage"]; //It would not create the graphs without using '[]'
$data_names[] = $myrow["member_id"]."(".$myrow["f_baggage"].")";
}while ($myrow=mysql_fetch_array($RESULT));
}
// Some data
$databary=array($data_names);
$months=$gDateLocale->GetShortMonth();
// New graph with a drop shadow
$graph = new Graph(600,200,'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
// Set title and subtitle
$graph->title->Set("Test Data");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary[]);
$b1->SetLegend($data_names);
//$b1->SetAbsWidth(6);
//$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($b1);
$graph->Stroke();
mysql_free_result($found);
Can anyone please advise me on where I am going wrong.