extranet/www/graphs/ratios_graph.php
2009-06-18 09:29:46 +00:00

41 lines
974 B
PHP

<?php
require_once './lib/phpchartdir.php';
# The data for the line chart
$data = unserialize(urldecode($_REQUEST['data']));
$firephp->log($data,'data');
foreach($data['data'] as $value){
$dataX1[] = $value['entreprise'];
$dataX2[] = $value['secteur'];
$labelsX[] = substr($value['date'],0,4);
}
$i=-100;
while($i>100){ $labelsY[] = $i;}
# Create a XYChart object of size 250 x 250 pixels
$c = new XYChart(350, 250);
$c->setPlotArea(55, 10, 280, 200);
$c->yAxis->setTitle($data['unite']);
$c->xAxis->setTitle("Années");
$c->xAxis->setWidth(2);
$c->yAxis->setWidth(2);
$legendObj = $c->addLegend(50, 10, false, "times.ttf", 9);
$legendObj->setBackground(Transparent);
$c->addLineLayer($dataX1, 0x0000ff, "Entreprise");
$c->addLineLayer($dataX2, 0x008C00, "Secteur");
# Set the labels.
$c->yAxis->setLabels($labelsY);
$c->yAxis->setLabelStep(10);
$c->xAxis->setLabels($labelsX);
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>