extranet/www/graphs/synthese_graph.php
2009-03-31 14:16:03 +00:00

40 lines
976 B
PHP

<?php
require_once './lib/phpchartdir.php';
# The data for the line chart
$data = unserialize(urldecode($_REQUEST['data']));
$unite = isset($_REQUEST['unite']) ? $_REQUEST['unite'] : 'KEUROS';
foreach($data as $value){
if ($unite=='KEUROS'){ $dataX[] = $value['value']/1000; }
else { $dataX[] = $value['value']; }
//$jour = substr($value['date'],6,2);
//$mois = substr($value['date'],4,2);
$annee = substr($value['date'],0,4);
$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(50, 10, 280, 200);
$c->yAxis->setTitle($unite);
$c->xAxis->setTitle("Années");
$c->xAxis->setWidth(2);
$c->yAxis->setWidth(2);
$c->addLineLayer($dataX);
# 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));
?>