1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_gantt.php'); |
---|
4 | |
---|
5 | $graph = new GanttGraph(); |
---|
6 | $graph->SetShadow(); |
---|
7 | |
---|
8 | // Add title and subtitle |
---|
9 | $graph->title->Set("A nice main title"); |
---|
10 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,12); |
---|
11 | $graph->subtitle->Set("(Draft version)"); |
---|
12 | |
---|
13 | // Show day, week and month scale |
---|
14 | $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH); |
---|
15 | |
---|
16 | // Instead of week number show the date for the first day in the week |
---|
17 | // on the week scale |
---|
18 | $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); |
---|
19 | |
---|
20 | // Make the week scale font smaller than the default |
---|
21 | $graph->scale->week->SetFont(FF_FONT0); |
---|
22 | |
---|
23 | // Use the short name of the month together with a 2 digit year |
---|
24 | // on the month scale |
---|
25 | $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR4); |
---|
26 | $graph->scale->month->SetFontColor("white"); |
---|
27 | $graph->scale->month->SetBackgroundColor("blue"); |
---|
28 | |
---|
29 | // Format the bar for the first activity |
---|
30 | // ($row,$title,$startdate,$enddate) |
---|
31 | $activity = new GanttBar(0,"Project","2001-12-21","2002-02-20"); |
---|
32 | |
---|
33 | // Yellow diagonal line pattern on a red background |
---|
34 | $activity->SetPattern(BAND_RDIAG,"yellow"); |
---|
35 | $activity->SetFillColor("red"); |
---|
36 | |
---|
37 | // Add a right marker |
---|
38 | $activity->rightMark->Show(); |
---|
39 | $activity->rightMark->SetType(MARK_FILLEDCIRCLE); |
---|
40 | $activity->rightMark->SetWidth(13); |
---|
41 | $activity->rightMark->SetColor("red"); |
---|
42 | $activity->rightMark->SetFillColor("red"); |
---|
43 | $activity->rightMark->title->Set("M5"); |
---|
44 | $activity->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,12); |
---|
45 | $activity->rightMark->title->SetColor("white"); |
---|
46 | |
---|
47 | // Set absolute height |
---|
48 | $activity->SetHeight(1); |
---|
49 | |
---|
50 | |
---|
51 | // Format the bar for the second activity |
---|
52 | // ($row,$title,$startdate,$enddate) |
---|
53 | $activity2 = new GanttBar(1,"Project","2001-12-21","2002-02-20"); |
---|
54 | |
---|
55 | // Yellow diagonal line pattern on a red background |
---|
56 | $activity2->SetPattern(BAND_RDIAG,"yellow"); |
---|
57 | $activity2->SetFillColor("red"); |
---|
58 | |
---|
59 | // Add a right marker |
---|
60 | $activity2->rightMark->Show(); |
---|
61 | $activity2->rightMark->SetType(MARK_FILLEDCIRCLE); |
---|
62 | $activity2->rightMark->SetWidth(13); |
---|
63 | $activity2->rightMark->SetColor("red"); |
---|
64 | $activity2->rightMark->SetFillColor("red"); |
---|
65 | $activity2->rightMark->title->Set("M5"); |
---|
66 | $activity2->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,12); |
---|
67 | $activity2->rightMark->title->SetColor("white"); |
---|
68 | |
---|
69 | // Set absolute height |
---|
70 | $activity2->SetHeight(1); |
---|
71 | |
---|
72 | |
---|
73 | // Finally add the bar to the graph |
---|
74 | $graph->Add($activity); |
---|
75 | $graph->Add($activity2); |
---|
76 | |
---|
77 | // Create a miletone |
---|
78 | $milestone = new MileStone(2,"Milestone","2002-01-15","2002-01-15"); |
---|
79 | $milestone->title->SetColor("black"); |
---|
80 | $milestone->title->SetFont(FF_FONT1,FS_BOLD); |
---|
81 | $graph->Add($milestone); |
---|
82 | |
---|
83 | // Add a vertical line |
---|
84 | $vline = new GanttVLine("2001-12-24","Phase 1"); |
---|
85 | $vline->SetDayOffset(0.5); |
---|
86 | //$graph->Add($vline); |
---|
87 | |
---|
88 | // ... and display it |
---|
89 | $graph->Stroke(); |
---|
90 | ?> |
---|