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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| <?php
include("jpgraph/jpgraph.php");
include("jpgraph/jpgraph_line.php");
include("jpgraph/jpgraph_date.php");
/*
// appel du script de connexion
require("mysql_connect.php");
// On r�cup�re le timestamp du dernier enregistrement, ici DateHeure
$sql="select max(DateHeure) from exterieur";
$query=mysql_query($sql);
$list=mysql_fetch_array($query);
// On d�termine le stop et le start de fa�on � r�cup�rer dans la prochaine requ�te que les donn�es des derni�res xx heures
$stop=$list[0];
$start=$stop-(86400*2);
//86400 secondes =24 heures donc 86400*2=48 heures 360060*60 *24 =1 jour
$sql = "SELECT DateHeure, Mesure FROM exterieur where DateHeure >= '$start' and DateHeure <= '$stop' ORDER BY 1";
$query=mysql_query($sql);
$i=0;
while ($list = mysql_fetch_assoc($query))
{
if (date("I",time())==0)
{
$time[$i]=($list['DateHeure']+3600)*1000;
}
else
{
$time[$i]=($list['DateHeure']+7200)*1000;
}
$Mesure[$i]=$list['Mesure']*1;
$i++;
}
*/
$i=0;
$seconde=0;
$bid_courante=array(20,10,15,25);
$times=array();
$bids=array();
while($seconde<86400)
{
$times[$i]=$seconde;
$bids[0][$i]=$bid_courante[0]+rand(0,10)/10;
$mesure_courante[0]=$bids[0][$i];
$bids[1][$i]=$bid_courante[1]+rand(0,10)/10;
$mesure_courante[1]=$bids[1][$i];
$bids[2][$i]=$bid_courante[2]+rand(0,10)/10;
$mesure_courante[2]=$bids[2][$i];
$bids[3][$i]=$bid_courante[3]+rand(0,10)/10;
$mesure_courante[3]=$bids[3][$i];
$seconde+=60*60;
$i+=1;
}
// Setup the bid graph
$graph = new Graph(600,250);
$graph->SetMargin(80,30,50,40);
// $graph->SetMarginColor('white');
$graph->SetScale('dateint');
$graph->title->Set('Current Bids');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->subtitle->Set('(Updated every 5 minutes)');
$graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
// Enable antialias
$graph->img->SetAntiAliasing();
// Setup the y-axis to show currency values
// $graph->yaxis->SetLabelFormatCallback('number_format');
// $graph->yaxis->SetLabelFormat('$%s');
//Use hour:minute format for the labels
$graph->xaxis->scale->SetDateFormat('H:i');
DEFINE('INTERVAL', 60);
// Force labels to only be displayed every 5 minutes
$graph->xaxis->scale->ticks->Set(INTERVAL);
// Adjust the start time for an "even" 5 minute, i.e. 5,10,15,20,25, ...
// $graph->xaxis->scale->SetTimeAlign(MINADJ_5);
// Create the plots using the dummy data created at the beginning
$line = array();
for( $i=0; $i < 4; $i++ ) {
$line[$i] = new LinePlot($bids[$i],$times);
// $line[$i]->mark->SetType(MARK_SQUARE);
}
$graph->Add($line);
// Send the graph back to the client
$graph->Stroke();
?> |
Partager