1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <?php
## ........... Fonction Importation du CSV ............... ##
function parse_csv_file($file, $columnheadings = false, $delimiter = ',', $enclosure = "\"") {
$row = 1;
$rows = array();
$handle = fopen($file, 'r');
while (($data = fgetcsv($handle, 1000, $delimiter, $enclosure )) !== FALSE) {
if (!($columnheadings == "false") && ($row == 1)) {
$headingTexts = $data;
} elseif (!($columnheadings == "false")) {
foreach ($data as $key => $value) {
unset($data[$key]);
$data[$headingTexts[$key]] = $value;
}
$rows[] = $data;
} else {
$rows[] = $data;
}
$row++;
}
fclose($handle);
return $rows;
}
$csv = parse_csv_file('C:\Documents and Settings\ghipeau\Bureau\EasyPHP1-8\www\xlsmagique\liste\exemple.csv', true, ',');
?>
<?php
## ........... Fonction Creation du graphe ............... ##
require_once "../../LinePlot.class.php";
$graph = new Graph(600, 400);
$graph->setAntiAliasing(TRUE);
$data = array(); /*selection du CSV pour tracer la courbe*/
$plot = new LinePlot($values);
$plot->setBackgroundColor(new Color(245, 245, 245));
$plot->hideLine(TRUE);
$plot->setFillColor(new Color(180, 180, 180, 75));
$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
$plot->yAxis->setLabelPrecision(2);
$plot->yAxis->setLabelNumber(6);
$heures=array
('00h00', '00h15', '00h30', '00h45', '01h00', '1h15', '1h30', '1h45', '2h00', '2h15', '2h30', '2h45', '3h00', '3h15', '3h30', '3h45', '4h00', '4h15', '4h30', '4h45', '5h00', '5h15', '5h30', '5h45', '6h00', '6h15', '6h30', '6h45', '7h00', '7h15', '7h30', '7h45', '8h00', '8h15', '8h30', '8h45', '9h00', '9h15', '9h30', '9h45', '10h00', '10h15', '10h30', '10h45', '11h00', '11h15', '11h30', '11h45', '12h00', '12h15', '12h30', '12h45', '13h00', '13h15','13h30', '13h45', '14h00', '14h15', '14h30', '14h45', '15h00', '15h15', '15h30', '15h45', '16h00', '16h15', '16h30', '16h45', '17h00', '17h15', '17h30', '17h45', '18h00', '18h15', '18h30', '18h45', '19h00', '19h15', '19h30', '19h45', '20h00', '20h15', '20h30', '20h45', '21h00', '21h15', '21h30', '21h45', '22h00', '22h15', '22h30', '22h45', '23h00', '23h15', '23h30', '23h45', '00h00');
$plot->xAxis->setLabelText ($heures); /*Heures à afficher sur les abscisses*/
$plot->setSpace(6, 6, 10, 10);
$plot->label->set($values);
$plot->label->move(0, -23);
$plot->label->setBackgroundGradient(
new LinearGradient(
new Color(250, 250, 250, 10),
new Color(255, 200, 200, 30),
0
)
);
$plot->label->border->setColor(new Color(150, 150, 150, 150));
$plot->label->setPadding(3, 1, 1, 0);
$graph->add($plot);
$graph->draw();
?> |
Partager