[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | // Gantt example
|
---|
| 3 | require_once ('jpgraph/jpgraph.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_gantt.php');
|
---|
| 5 |
|
---|
| 6 | // Basic Gantt graph
|
---|
| 7 | $graph = new GanttGraph();
|
---|
| 8 | $graph->title->Set("Gantt chart with title columns and icons");
|
---|
| 9 | $graph->title->SetFont(FF_ARIAL, FS_BOLD,12);
|
---|
| 10 | $graph->title->SetMargin(10);
|
---|
| 11 |
|
---|
| 12 | // Explicitely set the date range
|
---|
| 13 | // (Autoscaling will of course also work)
|
---|
| 14 | $graph->SetDateRange('2001-10-06','2002-4-10');
|
---|
| 15 |
|
---|
| 16 | // 1.5 line spacing to make more room
|
---|
| 17 | $graph->SetVMarginFactor(1.5);
|
---|
| 18 |
|
---|
| 19 | // Setup some nonstandard colors
|
---|
| 20 | $graph->SetMarginColor('darkgreen@0.95');
|
---|
| 21 | $graph->SetBox(true,'yellow:0.6',2);
|
---|
| 22 | $graph->SetFrame(true,'darkgreen',4);
|
---|
| 23 | $graph->scale->divider->SetColor('yellow:0.6');
|
---|
| 24 | $graph->scale->dividerh->SetColor('yellow:0.6');
|
---|
| 25 |
|
---|
| 26 | // Display month and year scale with the gridlines
|
---|
| 27 | $graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR);
|
---|
| 28 | $graph->scale->month->grid->SetColor('gray');
|
---|
| 29 | $graph->scale->month->grid->Show(true);
|
---|
| 30 | $graph->scale->year->grid->SetColor('gray');
|
---|
| 31 | $graph->scale->year->grid->Show(true);
|
---|
| 32 |
|
---|
| 33 | // For the titles we also add a minimum width of 100 pixels for the Task name column
|
---|
| 34 | $graph->scale->actinfo->SetColTitles(
|
---|
| 35 | array('Note','Task','Duration','Start','Finish'),array(30,100));
|
---|
| 36 | $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5');
|
---|
| 37 | $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
|
---|
| 38 | $graph->scale->actinfo->vgrid->SetStyle('solid');
|
---|
| 39 | $graph->scale->actinfo->vgrid->SetColor('gray');
|
---|
| 40 |
|
---|
| 41 | // Uncomment this to keep the columns but show no headers
|
---|
| 42 | //$graph->scale->actinfo->Show(false);
|
---|
| 43 |
|
---|
| 44 | // Setup the icons we want to use
|
---|
| 45 | $erricon = new IconImage(GICON_FOLDER,0.6);
|
---|
| 46 | $startconicon = new IconImage(GICON_FOLDEROPEN,0.6);
|
---|
| 47 | $endconicon = new IconImage(GICON_TEXTIMPORTANT,0.5);
|
---|
| 48 |
|
---|
| 49 | // Store the icons in the first column and use plain text in the others
|
---|
| 50 | $data = array(
|
---|
| 51 | array(0,array($erricon,"Pre-study","102 days","23 Nov '01","1 Mar '02")
|
---|
| 52 | , "2001-11-23","2002-03-1",FF_ARIAL,FS_NORMAL,8),
|
---|
| 53 | array(1,array($startconicon,"Prototype","21 days","26 Oct '01","16 Nov '01"),
|
---|
| 54 | "2001-10-26","2001-11-16",FF_ARIAL,FS_NORMAL,8),
|
---|
| 55 | array(2,array($endconicon,"Report","12 days","1 Mar '02","13 Mar '02"),
|
---|
| 56 | "2002-03-01","2002-03-13",FF_ARIAL,FS_NORMAL,8)
|
---|
| 57 | );
|
---|
| 58 |
|
---|
| 59 | // Create the bars and add them to the gantt chart
|
---|
| 60 | for($i=0; $i<count($data); ++$i) {
|
---|
| 61 | $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10);
|
---|
| 62 | if( count($data[$i])>4 )
|
---|
| 63 | $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
|
---|
| 64 | $bar->SetPattern(BAND_RDIAG,"yellow");
|
---|
| 65 | $bar->SetFillColor("gray");
|
---|
| 66 | $bar->progress->Set(0.5);
|
---|
| 67 | $bar->progress->SetPattern(GANTT_SOLID,"darkgreen");
|
---|
| 68 | $bar->title->SetCSIMTarget(array('#1'.$i,'#2'.$i,'#3'.$i,'#4'.$i,'#5'.$i),array('11'.$i,'22'.$i,'33'.$i));
|
---|
| 69 | $graph->Add($bar);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | // Output the chart
|
---|
| 73 | $graph->Stroke();
|
---|
| 74 |
|
---|
| 75 | ?>
|
---|
| 76 |
|
---|
| 77 |
|
---|