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

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 3.2 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2// Gantt hour + minute example
3require_once ('jpgraph/jpgraph.php');
4require_once ('jpgraph/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
71for($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");//d=1006858800,
82$vline = new GanttVLine("2001-11-27 9:00");//d=1006858800,
83$vline->SetWeight(5);
84$vline->SetDayOffset(0);
85$vline->title->Set("27/11 9:00");
86$vline->title->SetFont(FF_FONT1,FS_BOLD,10);
87$graph->Add($vline);
88
89$graph->Stroke();
90
91?>
92
93
Note: See TracBrowser for help on using the repository browser.