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
|
<?php
require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_line.php");
// Convertion timestamp en heure
function TimeCallback($aVal) {
return Date('H:i:s',$aVal);
}
// Mon tableau d'ordonnée contient mes valeurs en euros
$datay [] = ...
// Mon tableau d'abscisse contient les timestamps de mes valeurs en euros
$datax [] =
// Création du graphique
$graph = new Graph(900,500);
$graph->SetMargin(40,40,30,70);
$graph->title->Set('Recette');
// Echelle en x commence à minuit et fini à minuit le lendemain (le tout en timestamp)
$graph->SetScale("linlin","auto","auto",mktime(0, 00, 00, 04, 16, 2011),mktime(0, 0, 0, 04, 17, 2011));
// Mise de x-axis avec un format timestamp
$graph->xaxis->SetLabelFormatCallback('TimeCallback');
$graph->xaxis->SetLabelAngle(90);
$p1 = new LinePlot($datay,$datax);
$p1->SetColor("blue");
$p1->SetFillColor("blue@0.4");
$graph->Add($p1);
//Affichage
$graph->Stroke();
?> |
Partager