As we have shown in the previous examples constructing a Gantt chart consists of a number of repetitive tasks; Create the individual activity bars and add them to the graph.
Now when you have a basic understanding of how this works you are ready to appreciate a small helper method. GanttGraph::CreateSimple(). This method takes a few arrays of data which specifies you Gantt chart and then constructs this chart. By using this method you sacrifices a few adjustment possibilities for simplicity. This method is nothing magical it just takes the data for the activities,(start and end date, titles, progress, any constrains and so on) and constructs the activities and adds them to the graph.
The activities are specified in data array which for each activity have the following fields
So for example to create a Gantt chart consisting of two activities which are grouped and a milestone one would have to use something similar to the following code
$data = array(
array(0,ACTYPE_GROUP, "Phase 1", "2001-10-26", "2001-11-23", ""),
array(1,ACTYPE_NORMAL, " Label 2", "2001-10-26", "2001-11-13", "[KJ]"),
array(2,ACTYPE_NORMAL, " Label 3", "2001-11-20", "2001-11-22", "[EP]"),
array(3,ACTYPE_MILESTONE," Phase 1 Done", "2001-11-23", "M2") );
// Create the basic graph
$graph = new GanttGraph ();
$graph->title-> Set( "Gantt Graph using CreateSimple()");
// Setup scale
$graph->ShowHeaders( GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
// Add the specified activities
// .. and stroke the graph
This will then show up as
You may (slightly) modify the appearance of the simple Gantt charts by means of the methods GanttGraph::SetSimpleFont() and GanttGraph::SetSimpleStyle() But not anything else, remember that the purpose with this way of constructing graphs is to be simple. If you need full advanced control you have to construct all the activities in the "normal" way.
You can also specify constrains and progress for each bar by supplying additional data arrays to GanttGraph::CreateSimple().