1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | // Gantt example 30
|
---|
3 | // $Id: ganttex30.php,v 1.4 2003/05/30 20:12:43 aditus Exp $
|
---|
4 | require_once ('jpgraph/jpgraph.php');
|
---|
5 | require_once ('jpgraph/jpgraph_gantt.php');
|
---|
6 |
|
---|
7 | // Standard calls to create a new graph
|
---|
8 | $graph = new GanttGraph();
|
---|
9 | $graph->SetShadow();
|
---|
10 | $graph->SetBox();
|
---|
11 |
|
---|
12 | // Titles for chart
|
---|
13 | $graph->title->Set("General conversion plan");
|
---|
14 | $graph->subtitle->Set("(Revision: 2001-11-18)");
|
---|
15 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
|
---|
16 |
|
---|
17 | // For illustration we enable all headers.
|
---|
18 | $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
|
---|
19 |
|
---|
20 | // For the week we choose to show the start date of the week
|
---|
21 | // the default is to show week number (according to ISO 8601)
|
---|
22 | $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
|
---|
23 |
|
---|
24 | // Change the scale font
|
---|
25 | $graph->scale->week->SetFont(FF_FONT0);
|
---|
26 | $graph->scale->year->SetFont(FF_ARIAL,FS_BOLD,12);
|
---|
27 |
|
---|
28 |
|
---|
29 | // Setup some data for the gantt bars
|
---|
30 | $data = array(
|
---|
31 | array(0,"Group 1", "2001-10-29","2001-11-27",FF_FONT1,FS_BOLD,8),
|
---|
32 | array(1," Label 2", "2001-11-8","2001-12-14"),
|
---|
33 | array(2," Label 3", "2001-11-01","2001-11-8"),
|
---|
34 | array(4,"Group 2", "2001-11-07","2001-12-19",FF_FONT1,FS_BOLD,8),
|
---|
35 | array(5," Label 4", "2001-11-8","2001-12-19"),
|
---|
36 | array(6," Label 5", "2001-11-01","2001-11-8")
|
---|
37 | );
|
---|
38 |
|
---|
39 | for($i=0; $i<count($data); ++$i) {
|
---|
40 | $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",0.5);
|
---|
41 | if( count($data[$i])>4 )
|
---|
42 | $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
|
---|
43 |
|
---|
44 | // If you like each bar can have a shadow
|
---|
45 | // $bar->SetShadow(true,"darkgray");
|
---|
46 |
|
---|
47 | // For illustration lets make each bar be red with yellow diagonal stripes
|
---|
48 | $bar->SetPattern(BAND_RDIAG,"yellow");
|
---|
49 | $bar->SetFillColor("red");
|
---|
50 |
|
---|
51 | // To indicate progress each bar can have a smaller bar within
|
---|
52 | // For illustrative purpose just set the progress to 50% for each bar
|
---|
53 | $bar->progress->Set(0.5);
|
---|
54 |
|
---|
55 | // Each bar may also have optional left and right plot marks
|
---|
56 | // As illustration lets put a filled circle with a number at the end
|
---|
57 | // of each bar
|
---|
58 | $bar->rightMark->SetType(MARK_FILLEDCIRCLE);
|
---|
59 | $bar->rightMark->SetFillColor("red");
|
---|
60 | $bar->rightMark->SetColor("red");
|
---|
61 | $bar->rightMark->SetWidth(10);
|
---|
62 |
|
---|
63 | // Title for the mark
|
---|
64 | $bar->rightMark->title->Set("".$i+1);
|
---|
65 | $bar->rightMark->title->SetColor("white");
|
---|
66 | $bar->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,10);
|
---|
67 | $bar->rightMark->Show();
|
---|
68 |
|
---|
69 | // ... and add the bar to the gantt chart
|
---|
70 | $graph->Add($bar);
|
---|
71 | }
|
---|
72 |
|
---|
73 | // Create a milestone mark
|
---|
74 | $ms = new MileStone(7,"M5","2001-12-10","10/12");
|
---|
75 | $ms->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
76 | $graph->Add($ms);
|
---|
77 |
|
---|
78 | // Create a vertical line to emphasize the milestone
|
---|
79 | $vl = new GanttVLine("2001-12-10 13:00","Phase 1","darkred");
|
---|
80 | $vl->SetDayOffset(0.5); // Center the line in the day
|
---|
81 | $graph->Add($vl);
|
---|
82 |
|
---|
83 | // Output the graph
|
---|
84 | $graph->Stroke();
|
---|
85 |
|
---|
86 | // EOF
|
---|
87 | ?>
|
---|