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
| $connection=mysql_connect($host,$user,$password) or die("connexion au serveur impossible :trunk données aktuelles");
mysql_select_db("meteo");
/* REQUETE DE SELECTION DES DONNEES DANS LA BASE DE DONNEES MYSQL*/
$sql = 'SELECT t_interieur,t_exterieur, pluie ,hum_exterieur, pression, force_vent FROM aktuell ';
print_r(mysql_error());
$req = mysql_query($sql);
while ( ($data = mysql_fetch_assoc($req))!== false) {
$V1[] = $data['pluie'];
$V2[] = $data['t_exterieur'];
$V3[] = $data['hum_exterieur'];
$V4[] = $data['pression'];
$V5[] = $data['force_vent'];
$V6[] = $data['t_interieur'];
}
$ydata=array( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23);
/* Activation des bibliotheques */
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once("jpgraph/jpgraph_date.php");
require_once ('jpgraph/jpgraph_bar.php');
// constitution du graphique taille 500 pixels par 500 pixels
$graph = new Graph(500,500);
$graph->SetScale("textlin");
$graph->img->SetMargin(40,20,20,40);
$graph->title->Set('Evolution de la journee');
$graph->xaxis->SetTickLabels($ydata); /* l'axe du bas */
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6);
$graph->xgrid->SetColor('#E3E3E3');
// Les lignes qui vont apparaitre dans le graphique
$p1 = new LinePlot($V2);
$graph->Add($p1);
$p1->SetColor("#38FFFF");
$p1->SetLegend('Temperature exterieure');
$p1 = new LinePlot($V6);
$graph->Add($p1);
$p1->SetColor("#3019FF");
$p1->SetLegend('Temperature interieure');
$graph->legend->SetFrameWeight(1);
// Output line
$graph->Stroke();
echo "<center><img src='graph.png' /></center>";
?> |
Partager