| 1 | <?php // content="text/plain; charset=utf-8"
|
|---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
|---|
| 3 | require_once ('jpgraph/jpgraph_gantt.php');
|
|---|
| 4 | require_once ('jpgraph/jpgraph_flags.php');
|
|---|
| 5 |
|
|---|
| 6 | $graph = new GanttGraph(0,0);
|
|---|
| 7 | $graph->SetBox();
|
|---|
| 8 | $graph->SetShadow();
|
|---|
| 9 |
|
|---|
| 10 | // Add title and subtitle
|
|---|
| 11 | $graph->title->Set("Example with added texts");
|
|---|
| 12 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
|
|---|
| 13 |
|
|---|
| 14 | // Show day, week and month scale
|
|---|
| 15 | $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
|
|---|
| 16 |
|
|---|
| 17 | // Set table title
|
|---|
| 18 | $graph->scale->tableTitle->Set("(Rev: 1.22)");
|
|---|
| 19 | $graph->scale->tableTitle->SetFont(FF_FONT1,FS_BOLD);
|
|---|
| 20 | $graph->scale->SetTableTitleBackground("silver");
|
|---|
| 21 |
|
|---|
| 22 | // Modify the appearance of the dividing lines
|
|---|
| 23 | $graph->scale->divider->SetWeight(3);
|
|---|
| 24 | $graph->scale->divider->SetColor("navy");
|
|---|
| 25 | $graph->scale->dividerh->SetWeight(3);
|
|---|
| 26 | $graph->scale->dividerh->SetColor("navy");
|
|---|
| 27 |
|
|---|
| 28 | // Use the short name of the month together with a 2 digit year
|
|---|
| 29 | // on the month scale
|
|---|
| 30 | $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR2);
|
|---|
| 31 | $graph->scale->month->SetFontColor("white");
|
|---|
| 32 | $graph->scale->month->SetBackgroundColor("blue");
|
|---|
| 33 |
|
|---|
| 34 | // 0 % vertical label margin
|
|---|
| 35 | $graph->SetLabelVMarginFactor(1);
|
|---|
| 36 |
|
|---|
| 37 | // Format the bar for the first activity
|
|---|
| 38 | // ($row,$title,$startdate,$enddate)
|
|---|
| 39 | $activity = new GanttBar(0,"Project","2001-12-21","2002-01-07","[50%]");
|
|---|
| 40 |
|
|---|
| 41 | // Yellow diagonal line pattern on a red background
|
|---|
| 42 | $activity->SetPattern(BAND_RDIAG,"yellow");
|
|---|
| 43 | $activity->SetFillColor("red");
|
|---|
| 44 |
|
|---|
| 45 | // Set absolute height
|
|---|
| 46 | $activity->SetHeight(10);
|
|---|
| 47 |
|
|---|
| 48 | // Specify progress to 60%
|
|---|
| 49 | $activity->progress->Set(0.6);
|
|---|
| 50 | $activity->progress->SetPattern(BAND_HVCROSS,"blue");
|
|---|
| 51 |
|
|---|
| 52 | // Format the bar for the second activity
|
|---|
| 53 | // ($row,$title,$startdate,$enddate)
|
|---|
| 54 | $activity2 = new GanttBar(1,"Project","2001-12-21","2001-12-27","[30%]");
|
|---|
| 55 |
|
|---|
| 56 | // Yellow diagonal line pattern on a red background
|
|---|
| 57 | $activity2->SetPattern(BAND_RDIAG,"yellow");
|
|---|
| 58 | $activity2->SetFillColor("red");
|
|---|
| 59 |
|
|---|
| 60 | // Set absolute height
|
|---|
| 61 | $activity2->SetHeight(10);
|
|---|
| 62 |
|
|---|
| 63 | // Specify progress to 30%
|
|---|
| 64 | $activity2->progress->Set(0.3);
|
|---|
| 65 | $activity2->progress->SetPattern(BAND_HVCROSS,"blue");
|
|---|
| 66 |
|
|---|
| 67 | // Finally add the bar to the graph
|
|---|
| 68 | $graph->Add($activity);
|
|---|
| 69 | $graph->Add($activity2);
|
|---|
| 70 |
|
|---|
| 71 | // Add text to top left corner of graph
|
|---|
| 72 | $txt1 = new Text();
|
|---|
| 73 | $txt1->SetPos(5,2);
|
|---|
| 74 | $txt1->Set("Note:\nEstimate done w148");
|
|---|
| 75 | $txt1->SetFont(FF_ARIAL,FS_BOLD,12);
|
|---|
| 76 | $txt1->SetColor('darkred');
|
|---|
| 77 | $graph->Add($txt1);
|
|---|
| 78 |
|
|---|
| 79 | // Add text to the top bar
|
|---|
| 80 | $txt2 = new Text();
|
|---|
| 81 | $txt2->SetScalePos("2002-01-01",1);
|
|---|
| 82 | $txt2->SetFont(FF_ARIAL,FS_BOLD,12);
|
|---|
| 83 | $txt2->SetAlign('left','center');
|
|---|
| 84 | $txt2->Set("Remember this!");
|
|---|
| 85 | $txt2->SetBox('yellow');
|
|---|
| 86 | $graph->Add($txt2);
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | // Add a vertical line
|
|---|
| 90 | $vline = new GanttVLine("2001-12-24","Phase 1");
|
|---|
| 91 | $vline->SetDayOffset(0.5);
|
|---|
| 92 | //$graph->Add($vline);
|
|---|
| 93 |
|
|---|
| 94 | // ... and display it
|
|---|
| 95 | $graph->Stroke();
|
|---|
| 96 | ?>
|
|---|