extranet/www/graphs/pie.php
Michael RICOIS 579d4f2235 MAJ Ratios
2009-03-25 18:32:45 +00:00

73 lines
2.7 KiB
PHP

<?php
if (isset($_REQUEST['w']) && $_REQUEST['w']<>'') $w=$_REQUEST['w'];
else die();
if (isset($_REQUEST['h']) && $_REQUEST['h']<>'') $h=$_REQUEST['h'];
else die();
if (isset($_REQUEST['d']) && $_REQUEST['d']<>'') $tabData=unserialize(urldecode($_REQUEST['d']));
else die();
if (isset($_REQUEST['t']) && ($_REQUEST['t']<>'a' || $_REQUEST['t']<>'p' || $_REQUEST['t']<>'c')) $t=$_REQUEST['t'];
else die();
if (isset($_REQUEST['x']) && $_REQUEST['x']<>'') $x=$_REQUEST['x'];
else $x=round($w/2);
if (isset($_REQUEST['y']) && $_REQUEST['y']<>'') $y=$_REQUEST['y'];
else $y=round($h/2);
if (isset($_REQUEST['r']) && $_REQUEST['r']<>'') $radius=$_REQUEST['r'];
else { $radius=$x;
if ($y<$radius) $radius=$y;
$radius=round($radius*0.9);
}
require_once("./lib/phpchartdir.php");
# The data for the pie chart
$data = $tabData;
# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart($w, $h);
# The labels for the pie chart
if ($t=='a') {
$labels = array('Capital souscrit non appelé','Immo. incorporelles','Immo. corporelles','Immo. financières','Stocks','Avances et acptes versés','Créances clients','Autres créances', 'Disponibilités','Autres actifs');
$textBoxObj = $c->addTitle("Composition de l'actif", "timesbi.ttf", 15);
} elseif ($t=='c') {
$labels = array('Résultat Net','Impôts sociétés','Perte exceptionnelle','Perte financière','Amor./prov.','Charges fonctionnement','Autres achats externes','Achats de marchandises');
$textBoxObj = $c->addTitle("Compte de résultat", "timesbi.ttf", 15);
}
# Set the center of the pie at (180, 140) and the radius to 100 pixels
$c->setPieSize($x, $y, $radius);
//$c->setLabelPos(20, LineColor);
$c->setLabelLayout(SideLayout);
# Set the label box background color the same as the sector color, with glass effect,
# and with 5 pixels rounded corners
$t = $c->setLabelStyle();
$t->setBackground(SameAsMainColor, Transparent, glassEffect());
$t->setRoundedCorners(5);
# Set the border color of the sector the same color as the fill color. Set the line # color of the join line to black (0x0)
$c->setLineColor(SameAsMainColor, 0x000000);
# Set the start angle to 135 degrees may improve layout when there are many small
# sectors at the end of the data array (that is, data sorted in descending order). It
# is because this makes the small sectors position near the horizontal axis, where
# the text label has the least tendency to overlap. For data sorted in ascending
# order, a start angle of 45 degrees can be used instead.
$c->setStartAngle(135);
# Set the pie data and the pie labels
$c->setData($data, $labels);
$c->set3D(20);
# output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>