| 1 |
lars |
1 |
<?php
|
|
|
2 |
// Gantt hour + minute example
|
|
|
3 |
include ("../jpgraph.php");
|
|
|
4 |
include ("../jpgraph_gantt.php");
|
|
|
5 |
|
|
|
6 |
// Some sample Gantt data
|
|
|
7 |
$data = array(
|
|
|
8 |
array(0,array("Group 1","345 days","2004-03-01","2004-05-05"), "2001-11-27 10:00","2001-11-27 14:00",FF_FONT2,FS_NORMAL,0),
|
|
|
9 |
array(1,array(" Label one",' 122,5 days',' 2004-03-01',' 2003-05-05','MJ'), "2001-11-27 16:00","2001-11-27 18:00"),
|
|
|
10 |
array(2," Label two", "2001-11-27","2001-11-27 10:00"),
|
|
|
11 |
array(3," Label three", "2001-11-27","2001-11-27 08:00")
|
|
|
12 |
);
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
// Basic graph parameters
|
|
|
16 |
$graph = new GanttGraph();
|
|
|
17 |
$graph->SetMarginColor('darkgreen@0.8');
|
|
|
18 |
$graph->SetColor('white');
|
|
|
19 |
|
|
|
20 |
// We want to display day, hour and minute scales
|
|
|
21 |
$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR | GANTT_HMIN);
|
|
|
22 |
|
|
|
23 |
// We want to have the following titles in our columns
|
|
|
24 |
// describing each activity
|
|
|
25 |
$graph->scale->actinfo->SetColTitles(
|
|
|
26 |
array('Act','Duration','Start','Finish','Resp'));//,array(100,70,70,70));
|
|
|
27 |
|
|
|
28 |
// Uncomment the following line if you don't want the 3D look
|
|
|
29 |
// in the columns headers
|
|
|
30 |
//$graph->scale->actinfo->SetStyle(ACTINFO_2D);
|
|
|
31 |
|
|
|
32 |
$graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
|
|
|
33 |
|
|
|
34 |
//These are the default values for use in the columns
|
|
|
35 |
//$graph->scale->actinfo->SetFontColor('black');
|
|
|
36 |
//$graph->scale->actinfo->SetBackgroundColor('lightgray');
|
|
|
37 |
//$graph->scale->actinfo->vgrid->SetStyle('solid');
|
|
|
38 |
|
|
|
39 |
$graph->scale->actinfo->vgrid->SetColor('gray');
|
|
|
40 |
$graph->scale->actinfo->SetColor('darkgray');
|
|
|
41 |
|
|
|
42 |
// Setup day format
|
|
|
43 |
$graph->scale->day->SetBackgroundColor('lightyellow:1.5');
|
|
|
44 |
$graph->scale->day->SetFont(FF_ARIAL);
|
|
|
45 |
$graph->scale->day->SetStyle(DAYSTYLE_SHORTDAYDATE1);
|
|
|
46 |
|
|
|
47 |
// Setup hour format
|
|
|
48 |
$graph->scale->hour->SetIntervall(1);
|
|
|
49 |
$graph->scale->hour->SetBackgroundColor('lightyellow:1.5');
|
|
|
50 |
$graph->scale->hour->SetFont(FF_FONT0);
|
|
|
51 |
$graph->scale->hour->SetStyle(HOURSTYLE_H24);
|
|
|
52 |
$graph->scale->hour->grid->SetColor('gray:0.8');
|
|
|
53 |
|
|
|
54 |
// Setup minute format
|
|
|
55 |
$graph->scale->minute->SetIntervall(30);
|
|
|
56 |
$graph->scale->minute->SetBackgroundColor('lightyellow:1.5');
|
|
|
57 |
$graph->scale->minute->SetFont(FF_FONT0);
|
|
|
58 |
$graph->scale->minute->SetStyle(MINUTESTYLE_MM);
|
|
|
59 |
$graph->scale->minute->grid->SetColor('lightgray');
|
|
|
60 |
|
|
|
61 |
$graph->scale->tableTitle->Set('Phase 1');
|
|
|
62 |
$graph->scale->tableTitle->SetFont(FF_ARIAL,FS_NORMAL,12);
|
|
|
63 |
$graph->scale->SetTableTitleBackground('darkgreen@0.6');
|
|
|
64 |
$graph->scale->tableTitle->Show(true);
|
|
|
65 |
|
|
|
66 |
$graph->title->Set("Example of hours & mins scale");
|
|
|
67 |
$graph->title->SetColor('darkgray');
|
|
|
68 |
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
for($i=0; $i<count($data); ++$i) {
|
|
|
72 |
$bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3]);
|
|
|
73 |
if( count($data[$i])>4 )
|
|
|
74 |
$bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
|
|
|
75 |
$bar->SetPattern(BAND_RDIAG,"yellow");
|
|
|
76 |
$bar->SetFillColor("gray");
|
|
|
77 |
$graph->Add($bar);
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
$vline = new GanttVLine("2001-11-27 13:00");
|
|
|
82 |
$vline->title->Set("27/11 13:00");
|
|
|
83 |
$vline->title->SetFont(FF_FONT1,FS_BOLD,10);
|
|
|
84 |
$graph->Add($vline);
|
|
|
85 |
|
|
|
86 |
$graph->Stroke();
|
|
|
87 |
|
|
|
88 |
?>
|
|
|
89 |
|
|
|
90 |
|