extranet/www/pages/synthese_graph_linecompare.php
2009-03-26 11:44:14 +00:00

68 lines
2.8 KiB
PHP

<?php
//Graphique style linecompare / CA / FR / BFR
require_once '../graphs/lib/phpchartdir.php';
# The data for the chart
$dataY0 = array(4, 4.5, 5, 5.25, 5.75, 5.25, 5, 4.5, 4, 3, 2.5, 2.5);
$dataX0 = array(chartTime(1997, 1, 1), chartTime(1998, 6, 25), chartTime(1999, 9, 6),
chartTime(2000, 2, 6), chartTime(2000, 9, 21), chartTime(2001, 3, 4), chartTime(
2001, 6, 8), chartTime(2002, 2, 4), chartTime(2002, 5, 19), chartTime(2002, 8, 16
), chartTime(2002, 12, 1), chartTime(2003, 1, 1));
$dataY1 = array(7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5, 4, 3.5, 3.5);
$dataX1 = array(chartTime(1997, 1, 1), chartTime(1997, 7, 1), chartTime(1997, 12, 1),
chartTime(1999, 1, 15), chartTime(1999, 6, 9), chartTime(2000, 3, 3), chartTime(
2000, 8, 13), chartTime(2001, 5, 5), chartTime(2001, 9, 16), chartTime(2002, 3,
16), chartTime(2002, 6, 1), chartTime(2003, 1, 1));
$dataY2 = array(8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8);
$dataX2 = array(chartTime(1997, 1, 1), chartTime(1998, 6, 25), chartTime(1999, 9, 6),
chartTime(2000, 2, 6), chartTime(2000, 9, 21), chartTime(2001, 3, 4), chartTime(
2001, 6, 8), chartTime(2002, 2, 4), chartTime(2002, 5, 19), chartTime(2002, 8, 16
), chartTime(2002, 12, 1), chartTime(2003, 1, 1));
$c = new XYChart(580, 300, 0xcccccc, 0x000000, 1);
$c->setPlotArea(40, 60, 525, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
$c->yAxis->setTitle("KEUROS");
$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, 0, false, "arialbd.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 black (000000) step line layer to the chart and set the line width to 2 pixels
$layer2 = $c->addStepLineLayer($dataY2, 0x000000, "CHIFFRE D'AFFAIRES");
$layer2->setXData($dataX2);
$layer2->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, 0x8099ff99);
// output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>