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 77 78 79 80
| <?php
include_once '../include/jpgraph-2.3.4/src/jpgraph.php';
include_once '../include/jpgraph-2.3.4/src/jpgraph_bar.php';
session_start();
// We need some data
$datag = $_SESSION['sdg'];
session_unregister('sdg');
$data = $_SESSION['sd'];
session_unregister('sd');
if(isset($_SESSION['sl'])){
$datal = $_SESSION['sl'];
session_unregister('sl');
}
$taille = sizeof($data[0]['donnee']);
// Setup the graph.
$graph = new Graph($taille *20 + 450,400,"auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(150,200,25,150);
$graph->SetMarginColor("white");
$graph->SetFrame(false);
$graph->SetShadow();
$graph->title->Set($datag['nomgraph']);
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,10);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datag['nomx']);
$graph->xaxis->SetLabelAngle(30);
// Set X-axis at the minimum value of Y-axis (default will be at 0)
$graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis
// Adjust the position of the legend box
$graph->legend->Pos(0.02,0.15);
// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5', 5);
$graph->legend->SetFillColor('white');
for($i=0 ; $i<$datag['nbcouche'] ; $i++){
$bplot[$i] = new BarPlot($data[$i]['donnee']);
$bplot[$i]->SetLegend($data[$i]['nom']);
$bplot[$i]->value->Show();
$bplot[$i]->value->SetFormat("%d");
$bplot[$i]->value->SetColor("#000000");
$bplot[$i]->SetFillGradient("#".$datag['couleur'][$i],"#dddddd",GRAD_LEFT_REFLECTION);
if(isset($_REQUEST['sl'])){
$bplot[$i]->SetCSIMTargets($datal[$i]['lien'],$datal[$i]['comment']);
}
}
$gbplot = new AccBarPlot($bplot);
$graph->Add($gbplot);
// Finally send the graph to the browser
if(isset($_REQUEST['sl'])){
$graph->StrokeCSIM();
}else{
$graph->Stroke();
}
?> |
Partager