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
|
<?php
include ("C:\wamp\www\Stage_pageweb\jpgraph-2.3\src\jpgraph.php");
include ("C:\wamp\www\Stage_pageweb\jpgraph-2.3\src\jpgraph_line.php");
$connect= mysql_connect("localhost","root","") or die("Impossible de se connecter");
$db_selected=mysql_select_db('stage',$connect) or die('Impossible de sélectionner la BD');
$heure_d=' 00:00:00';
$heure_f=' 23:59:59';
$date_d=$_POST['date_d'].$heure_d;
$date_f=$_POST['date_f'].$heure_f;
$capteur_d=$_POST['capteur_d'];
$capteur_f=$_POST['capteur_f'];
///////////////////////////////////////////////////////////////////////////////////////
if ($_POST['display']=='highvoltage'){
$requete = "SELECT voltage,datetime
FROM testtable_data
WHERE '$date_d'<=datetime AND datetime<='$date_f'
AND '$capteur_d'<=id_captor AND id_captor<='$capteur_f'";
$pg_result = mysql_query($requete);
$voltage=array();
$datetime=array();
$matrice = array();
$i=0;
while ($row = mysql_fetch_array($pg_result, MYSQL_ASSOC)) {
$datetime[$i]=($row["datetime"]);
$voltage[$i]=($row["voltage"]);
$matrice[$i] = array($datetime[$i],$voltage[$i]);
$i++;
}
$graph = new Graph(900,600,"auto");
$graph->SetShadow();
$graph->SetScale("textlin");
$graph->yaxis->SetColor("black","red");
$graph->title->Set("Highvoltage of captors $capteur_d to $capteur_f");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->img->SetMargin(30,140,30,140);
$graph->legend->Pos(0.03,0.5,"right","center");
$graph->xaxis->SetTextTickInterval(1);
$graph->xaxis->SetTextLabelInterval(1);
$graph->xaxis->SetTickLabels($datetime);
$graph->xaxis->SetLabelAngle(90);
$p1 = new LinePlot($voltage);
$p1->SetColor("red");
$p1->SetLegend("Voltage");
$graph->Add($p1);
$graph->Stroke();
mysql_close($connect);
}
?> |
Partager