83 lines
3.0 KiB
PHP
83 lines
3.0 KiB
PHP
<?php
|
|
//Graphique style linecompare / CA / FR / BFR
|
|
require_once realpath(dirname(__FILE__)).'/lib/phpchartdir.php';
|
|
|
|
//Définition des valeurs pour le graph
|
|
$dataBFR = array();
|
|
$dataFR = array();
|
|
$dataCA = array();
|
|
|
|
$data = unserialize(file_get_contents(realpath(dirname(__FILE__)).'/../../cache/'.$_REQUEST['d']));
|
|
$firephp->log($data, 'data');
|
|
$i=0;
|
|
//Parcourir les années
|
|
foreach($data as $item){
|
|
//$jour = substr($item['date'],6,2);
|
|
//$mois = substr($item['date'],4,2);
|
|
$annee = substr($item['date'],0,4);
|
|
$dataBFR['x'][$i] = $dataFR['x'][$i] = $dataCA['x'][$i] = $dataEBE['x'][$i] = chartTime((int)$annee, 1, 1);
|
|
$dataBFR['y'][$i] = $item['r236'];
|
|
$dataFR['y'][$i] = $item['r235'];
|
|
$dataCA['y'][$i] = $item['r6'];
|
|
$dataEBE['y'][$i] = $item['r146'];
|
|
$i++;
|
|
}
|
|
|
|
# The data for the chart
|
|
$dataY0 = $dataBFR['y'];
|
|
$dataX0 = $dataBFR['x'];
|
|
|
|
$dataY1 = $dataFR['y'];
|
|
$dataX1 = $dataFR['x'];
|
|
|
|
$dataY2 = $dataCA['y'];
|
|
$dataX2 = $dataCA['x'];
|
|
|
|
$dataY3 = $dataEBE['y'];
|
|
$dataX3 = $dataEBE['x'];
|
|
|
|
$c = new XYChart(580, 350, 0xcccccc, 0x000000, 1);
|
|
$c->addTitle("Synthèse *", "timesbi.ttf", 15, 0x000000);
|
|
$c->addText(60, 320, "* Elements financier rapportés à 12 mois" );
|
|
|
|
$c->setPlotArea(60, 80, 500, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
|
|
$c->yAxis->setTitle("KEUROS","timesbi.ttf",10);
|
|
$c->xAxis->setTitle( "<*block,valign=absmiddle*>Anné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.
|
|
$legendObj = $c->addLegend(55, 30, false, "times.ttf", 9);
|
|
$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);
|
|
|
|
// 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");
|
|
$layer2->setXData($dataX2);
|
|
$layer2->setLineWidth(2);
|
|
|
|
// 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);
|
|
|
|
# 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, 0x8044ff44);
|
|
|
|
// output the chart
|
|
header("Content-type: image/png");
|
|
print($c->makeChart2(PNG));
|
|
?>
|