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 81 82
|
$stats = array ('available' => 0, 'unavailable' => 0);
while ($appstatus = oci_fetch_assoc($res['stmt']))
{
foreach ($appstatus as $champ => $val)
{
$status[$champ] = $val;
}
if ($status['STATSAPPLI'] == '0')
{
$stats['unavailable'] += $status['NB_STATSAPPLI'];
}
else if ($status['STATSAPPLI'] == '1')
{
$stats['available'] += $status['NB_STATSAPPLI'];
}
}
//if we have no state, we print a message
if ($stats['available'] == 0 && $stats['unavailable'] == 0)
{
echo '<p>No stats availables.</p>';
}
//else we print the graph
else
{
//creating the graphic with the size
$graph = new Graph(650, 350);
//adding a shadow
$graph->shadow->setPosition(Shadow::RIGHT_BOTTOM);
$graph->shadow->setSize(4);
//background
$graph->setBackgroundGradient(
new LinearGradient(
new Color(240, 240, 240, 0),
new White,
0
)
);
//we create the camembert with the values of the array
$pie = new Pie(array_values($stats));
//percentages with a tenth precision
$pie->setLabelPrecision(1);
//adding the legend
$pie->setLegend(array_keys($stats));
//repositioning the legend
$pie->legend->setPosition(1.45, .25);
//moving the camembert to the bottom-left
$pie->setCenter(.36, .58);
//resizing the camembert
$pie->setSize(.65, .65);
//adding a 3D effect
$pie->set3D(30);
//adding a title
$pie->title->set('Graphic for the application '.$appname.' (project '.$projname.')');
//replacing
$pie->title->move(0, -60);
//designing
$pie->title->setFont(new TuffyBold(14));
$pie->title->setBackgroundColor(new White(50));
$pie->title->setPadding(5, 5, 2, 2);
$pie->title->border->setColor(new Black());
//adding the camembert to the graphic
$graph->add($pie);
//we draw the graphic
$graph->draw(DCROOT."/pictures/graph.png");
echo '<img src="pictures/graph.png" alt="Stats" />';
} |
Partager