source: trunk/xgraph/jpgraph/Examples/ganttex12.php @ 42

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