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 | $graph = new GanttGraph(); |
---|
7 | |
---|
8 | $graph->title->Set("Adding a spaning title"); |
---|
9 | |
---|
10 | // Setup some "very" nonstandard colors |
---|
11 | $graph->SetMarginColor('lightgreen@0.8'); |
---|
12 | $graph->SetBox(true,'yellow:0.6',2); |
---|
13 | $graph->SetFrame(true,'darkgreen',4); |
---|
14 | $graph->scale->divider->SetColor('yellow:0.6'); |
---|
15 | $graph->scale->dividerh->SetColor('yellow:0.6'); |
---|
16 | |
---|
17 | // Explicitely set the date range |
---|
18 | // (Autoscaling will of course also work) |
---|
19 | $graph->SetDateRange('2001-11-06','2002-1-10'); |
---|
20 | |
---|
21 | // Display month and year scale with the gridlines |
---|
22 | $graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR | GANTT_HWEEK ); |
---|
23 | $graph->scale->month->grid->SetColor('gray'); |
---|
24 | $graph->scale->month->grid->Show(true); |
---|
25 | $graph->scale->year->grid->SetColor('gray'); |
---|
26 | $graph->scale->year->grid->Show(true); |
---|
27 | |
---|
28 | |
---|
29 | //Setup spanning title |
---|
30 | $graph->scale->tableTitle->Set( 'Phase 1' ); |
---|
31 | $graph->scale->tableTitle->SetFont( FF_ARIAL , FS_NORMAL , 16 ); |
---|
32 | $graph->scale->SetTableTitleBackground( 'darkgreen@0.6' ); |
---|
33 | $graph->scale->tableTitle->Show( true ); |
---|
34 | |
---|
35 | // Setup activity info |
---|
36 | |
---|
37 | // For the titles we also add a minimum width of 100 pixels for the Task name column |
---|
38 | $graph->scale->actinfo->SetColTitles(array('Name','Duration','Start','Finish'),array(100)); |
---|
39 | $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5'); |
---|
40 | $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10); |
---|
41 | $graph->scale->actinfo->vgrid->SetStyle('solid'); |
---|
42 | $graph->scale->actinfo->vgrid->SetColor('gray'); |
---|
43 | |
---|
44 | // Data for our example activities |
---|
45 | $data = array( |
---|
46 | array(0,array("Pre-study","102 days","23 Nov '01","1 Mar '02") |
---|
47 | , "2001-11-23","2002-03-1",FF_ARIAL,FS_NORMAL,8), |
---|
48 | array(1,array("Prototype","21 days","26 Oct '01","16 Nov '01"), |
---|
49 | "2001-10-26","2001-11-16",FF_ARIAL,FS_NORMAL,8), |
---|
50 | array(2,array("Report","12 days","1 Mar '02","13 Mar '02"), |
---|
51 | "2002-03-01","2002-03-13",FF_ARIAL,FS_NORMAL,8) |
---|
52 | ); |
---|
53 | |
---|
54 | // Create the bars and add them to the gantt chart |
---|
55 | for($i=0; $i<count($data); ++$i) { |
---|
56 | $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10); |
---|
57 | if( count($data[$i])>4 ) |
---|
58 | $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]); |
---|
59 | $bar->SetPattern(BAND_RDIAG,"yellow"); |
---|
60 | $bar->SetFillColor("gray"); |
---|
61 | $bar->progress->Set(0.5); |
---|
62 | $bar->progress->SetPattern(GANTT_SOLID,"darkgreen"); |
---|
63 | $graph->Add($bar); |
---|
64 | } |
---|
65 | |
---|
66 | // Output the chart |
---|
67 | $graph->Stroke(); |
---|
68 | |
---|
69 | ?> |
---|
70 | |
---|
71 | |
---|