extranet/www/graphs/synthese_graph_linecompare.php

82 lines
2.9 KiB
PHP
Raw Normal View History

2009-03-25 18:32:45 +00:00
<?php
//Graphique style linecompare / CA / FR / BFR
2009-03-30 16:41:42 +00:00
require_once './lib/phpchartdir.php';
2009-03-30 16:27:40 +00:00
//D<>finition des valeurs pour le graph
$dataBFR = array();
$dataFR = array();
$dataCA = array();
$data = unserialize(urldecode($_REQUEST['data']));
$firephp->log($data, 'data');
2009-03-31 14:16:03 +00:00
$i=0;
2009-03-30 16:27:40 +00:00
//Parcourir les ann<6E>es
foreach($data as $item){
2009-03-31 14:16:03 +00:00
//$jour = substr($item['date'],6,2);
//$mois = substr($item['date'],4,2);
2009-03-30 16:27:40 +00:00
$annee = substr($item['date'],0,4);
2009-03-31 14:16:03 +00:00
$dataBFR['x'][$i] = $dataFR['x'][$i] = $dataCA['x'][$i] = $dataEBE['x'][$i] = chartTime((int)$annee, 1, 1);
2009-03-31 15:19:54 +00:00
$dataBFR['y'][$i] = $item['r236']/1000;
$dataFR['y'][$i] = $item['r235']/1000;
$dataCA['y'][$i] = $item['r6']/1000;
2009-03-30 16:27:40 +00:00
$dataEBE['y'][$i] = $item['r140']/1000;
$i++;
}
2009-03-25 18:32:45 +00:00
# The data for the chart
2009-03-30 16:27:40 +00:00
$dataY0 = $dataBFR['y'];
$dataX0 = $dataBFR['x'];
2009-03-25 18:32:45 +00:00
2009-03-30 16:27:40 +00:00
$dataY1 = $dataFR['y'];
$dataX1 = $dataFR['x'];
2009-03-25 18:32:45 +00:00
2009-03-30 16:27:40 +00:00
$dataY2 = $dataCA['y'];
$dataX2 = $dataCA['x'];
$dataY3 = $dataEBE['y'];
$dataX3 = $dataEBE['x'];
2009-03-31 15:19:54 +00:00
$c = new XYChart(580, 320, 0xcccccc, 0x000000, 1);
$c->addTitle("Synth<EFBFBD>se <20> 12 mois", "timesbi.ttf", 15, 0x000000);
$c->setPlotArea(60, 80, 500, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
2009-03-25 18:32:45 +00:00
$c->yAxis->setTitle("KEUROS");
$c->xAxis->setTitle( "<*block,valign=absmiddle*>Ann<6E>es<*/*>");
$c->xAxis->setWidth(2);
$c->yAxis->setWidth(2);
// Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9 pts
// Arial Bold font. Set the background and border color to Transparent.
2009-03-31 15:19:54 +00:00
$legendObj = $c->addLegend(55, 30, false, "times.ttf", 9);
2009-03-25 18:32:45 +00:00
$legendObj->setBackground(Transparent);
// Add a blue (0000ff) step line layer to the chart and set the line width to 2 pixels
$layer1 = $c->addStepLineLayer($dataY1, 0x0000ff, "FONDS DE ROULEMENT");
$layer1->setXData($dataX1);
$layer1->setLineWidth(2);
// Add a red (ff0000) step line layer to the chart and set the line width to 2 pixels
$layer0 = $c->addStepLineLayer($dataY0, 0xff0000, "BESOIN EN FONDS DE ROULEMENT");
$layer0->setXData($dataX0);
$layer0->setLineWidth(2);
2009-03-30 16:27:40 +00:00
// Add a green (00ff00) step line layer to the chart and set the line width to 2 pixels
$layer2 = $c->addStepLineLayer($dataY2, 0x00ff00, "CHIFFRE D'AFFAIRES");
2009-03-25 18:32:45 +00:00
$layer2->setXData($dataX2);
$layer2->setLineWidth(2);
2009-03-30 16:27:40 +00:00
// Add a black (000000) step line layer style dash to the chart and set the line width to 2 pixels
$layer3 = $c->addStepLineLayer($dataY3, $c->dashLineColor(0x000000, DashLine), "EXCEDENT BRUT D'EXPLOITATION");
$layer3->setXData($dataX3);
$layer3->setLineWidth(2);
2009-03-25 18:32:45 +00:00
# If the FR line gets above the BFR line, color to area between the lines red (ff0000)
$c->addInterLineLayer($layer0->getLine(0), $layer1->getLine(0), 0xff0000, Transparent);
# If the FR line gets below the lower BFR line, color to area between the lines light green (8099ff99)
$c->addInterLineLayer($layer0->getLine(0), $layer1->getLine(0), Transparent, 0x8099ff99);
// output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>