gorio Posted August 31, 2011 Share Posted August 31, 2011 Hi Freaks, I am trying to make a gantt chart with data stored in a mysql database but I am having problems with the syntax. I can create the chart ok by hard coding, and I can see the database query is returning the expected data, but I just can't quite figure the correct syntax to pass the data to jpgraph to get the result. simplified code: <?php require_once('connections/manager.php'); ?> <?php mysql_select_db($database_manager, $manager); $query_project = "SELECT `task`, `dateStart`, `dateFinish`, `managerName` FROM `test`"; $project = mysql_query($query_project, $manager) or die(mysql_error()); $row_project = mysql_fetch_assoc($project); $totalRows_project = mysql_num_rows($project); require_once ('jpgraph/jpgraph.php'); require_once ('jpgraph/jpgraph_gantt.php'); $graph = new GanttGraph(800); $graph->title->Set("Project"); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph->scale->day->SetStyle(DAYSTYLE_SHORTDATE4); $graph->scale->day->grid->Show(); $graph->scale->month->SetStyle(MONTHSTYLE_LONGNAME); $graph->scale->week->SetFont(FF_FONT1); $n=0; do { $data[]=array(array($n,$row_project["task"],$row_project["dateStart"],$row_project["dateFinish"],$row_project["managerName"])); ++$n; //echo "\$bar".$n." = new GanttBar(".$n.",\"".$row_project["task"]."\",\"".$row_project["dateStart"]."\",\"".$row_project["dateFinish"]."\",\"".$row_project["managerName"]."\")"; }while ($row_project=mysql_fetch_array($project)); $graph->Add(array($data)); // I figure this is where I'm going wrong? $graph->Stroke(); mysql_free_result($project); ?> This is giving me the following error: Fatal error: Call to a member function GetMaxDate() on a non-object in jpgraph/jpgraph_gantt.php on line 630 Other variations bring up an error graphic saying no date value, so as I said I'm pretty sure it's a problem with passing the array to jpgraph... There don't appear to be any forums at jpgraph, and other searching isn't giving me any joy so any pointers would be most welcome. Quote Link to comment Share on other sites More sharing options...
gorio Posted August 31, 2011 Author Share Posted August 31, 2011 ok I figured it out, the corrected relevent lines are: $n=0; do { $data[]=array($n++,ACTYPE_NORMAL,$row_project["task"],$row_project["dateStart"],$row_project["dateFinish"],$row_project["managerName"])); }while ($row_project=mysql_fetch_array($project)); $graph->CreateSimple($data); hope this helps anyone losing hair like me Quote Link to comment Share on other sites More sharing options...
yon90 Posted September 23, 2014 Share Posted September 23, 2014 (edited) i copy ur corrected code but still not display the chart it show Notice: Undefined offset: 4 in C:\xampp\htdocs\gant\jpgraph_gantt.php on line 410Notice: Undefined offset: 5 in C:\xampp\htdocs\gant\jpgraph_gantt.php on line 458JpGraph Error: 6017 Unknown date format in GanttScale (%s). maybe there is something wrong in date format...im using xampp as web server, the date format in YYYY/MM/DD and i change the style code to code below then still the same output display $graph->scale->day->SetStyle(DAYSTYLE_CUSTOM); Edited September 23, 2014 by yon90 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.