1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <?php
// content="text/plain; charset=utf-8"
// Gantt example
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_gantt.php');
$graph = new GanttGraph();
$graph->title->Set("Only month & year scale");
// Setup some "very" nonstandard colors
$graph->SetMarginColor('lightgreen@0.8');
$graph->SetBox(true,'yellow:0.6',2);
$graph->SetFrame(true,'darkgreen',4);
$graph->scale->divider->SetColor('yellow:0.6');
$graph->scale->dividerh->SetColor('yellow:0.6');
// Explicitely set the date range
// (Autoscaling will of course also work)
$graph->SetDateRange('2015-03-30','2016-4-10');
// Display month and year scale with the gridlines
$graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR);
$graph->scale->month->grid->SetColor('gray');
$graph->scale->month->grid->Show(true);
$graph->scale->year->grid->SetColor('gray');
$graph->scale->year->grid->Show(true);
// Setup activity info
// For the titles we also add a minimum width of 100 pixels for the Task name column
$graph->scale->actinfo->SetColTitles(
array('Name','Duration','Start','Finish'),array(100));
$graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5');
$graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
$graph->scale->actinfo->vgrid->SetStyle('solid');
$graph->scale->actinfo->vgrid->SetColor('gray');
//connexion à la base de donnée
mysql_connect('localhost', 'root', '');
mysql_select_db('gantt') ;
$requete=("SELECT nom , durée, date début, date fin FROM ga ");
$req=mysql_query($requete);
while($ligne=mysql_fetch_array($req))
{
$name=$ligne[0];
$duration=$ligne[1];
$db=$ligne[2];
$df=$ligne[3];
// Data for our example activities
$data = array(
array(0,array("$name","$duration","$db","$df")
, "$db","$df",FF_ARIAL,FS_NORMAL,8),
);
}
// Create the bars and add them to the gantt chart
for($i=0; $i<count($data); ++$i) {
$bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10);
if( count($data[$i])>4 )
$bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
$bar->SetPattern(BAND_RDIAG,"yellow");
$bar->SetFillColor("gray");
$bar->progress->Set(0.5);
$bar->progress->SetPattern(GANTT_SOLID,"darkgreen");
$graph->Add($bar);
}
// Output the chart
$graph->Stroke();
?> |
Partager