[42] | 1 | <?php // content="text/plain; charset=utf-8" |
---|
| 2 | |
---|
| 3 | // Gantt column font array example |
---|
| 4 | |
---|
| 5 | require_once ('../jpgraph.php'); |
---|
| 6 | require_once ('../jpgraph_gantt.php'); |
---|
| 7 | |
---|
| 8 | // Setup a basic Gantt graph |
---|
| 9 | $graph = new GanttGraph(); |
---|
| 10 | $graph->SetMarginColor('gray:1.7'); |
---|
| 11 | $graph->SetColor('white'); |
---|
| 12 | |
---|
| 13 | // Setup the graph title and title font |
---|
| 14 | $graph->title->Set("Example of column fonts"); |
---|
| 15 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,14); |
---|
| 16 | |
---|
| 17 | // Show three headers |
---|
| 18 | $graph->ShowHeaders(GANTT_HDAY | GANTT_HMONTH| GANTT_HYEAR); |
---|
| 19 | |
---|
| 20 | // Set the column headers and font |
---|
| 21 | $graph->scale->actinfo->SetColTitles( array('Name','Start','End'),array(100)); |
---|
| 22 | $graph->scale->actinfo->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
| 23 | |
---|
| 24 | // Some "dummy" data to be dsiplayed |
---|
| 25 | $data = array( |
---|
| 26 | array(0,'Group 1', '2001-11-27','2001-12-05'), |
---|
| 27 | array(1,' Activity 1', '2001-11-27','2001-11-29'), |
---|
| 28 | array(2,' Activity 2', '2001-11-28','2001-12-05'), |
---|
| 29 | array(3,'Group 2', '2001-11-29','2001-12-10'), |
---|
| 30 | array(4,' Activity 1', '2001-11-29','2001-12-03'), |
---|
| 31 | array(5,' Activity 2', '2001-12-01','2001-12-10'), |
---|
| 32 | |
---|
| 33 | ); |
---|
| 34 | |
---|
| 35 | // Format and add the Gantt bars to the chart |
---|
| 36 | $n = count($data); |
---|
| 37 | for($i=0; $i < $n; ++$i) { |
---|
| 38 | if( $i === 0 || $i === 3 ) { |
---|
| 39 | // Format the group bars |
---|
| 40 | $bar = new GanttBar($data[$i][0],array($data[$i][1],$data[$i][2],$data[$i][3]),$data[$i][2],$data[$i][3],'',0.35); |
---|
| 41 | |
---|
| 42 | // For each group make the name bold but keep the dates as the default font |
---|
| 43 | $bar->title->SetColumnFonts(array(array(FF_ARIAL,FS_BOLD,11))); |
---|
| 44 | |
---|
| 45 | // Add group markers |
---|
| 46 | $bar->leftMark->SetType( MARK_LEFTTRIANGLE ); |
---|
| 47 | $bar->leftMark->Show(); |
---|
| 48 | $bar->rightMark->SetType( MARK_RIGHTTRIANGLE ); |
---|
| 49 | $bar->rightMark->Show(); |
---|
| 50 | $bar->SetFillColor('black'); |
---|
| 51 | $bar->SetPattern(BAND_SOLID,'black'); |
---|
| 52 | } |
---|
| 53 | else { |
---|
| 54 | // Format the activity bars |
---|
| 55 | $bar = new GanttBar($data[$i][0],array($data[$i][1],$data[$i][2],$data[$i][3]),$data[$i][2],$data[$i][3],'',0.45); |
---|
| 56 | $bar->SetPattern(BAND_RDIAG,'black'); |
---|
| 57 | $bar->SetFillColor('orange'); |
---|
| 58 | } |
---|
| 59 | // Default font |
---|
| 60 | $bar->title->SetFont(FF_ARIAL,FS_NORMAL,10); |
---|
| 61 | $graph->Add($bar); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | // Send back the graph to the client |
---|
| 65 | $graph->Stroke(); |
---|
| 66 | ?> |
---|
| 67 | |
---|
| 68 | |
---|