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(50, 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)); ?>