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
| <?php
require_once ('C:\wamp64\www\Projet\jpgraph\jpgraph-4.3.5\src\jpgraph.php');
require_once ('C:\wamp64\www\Projet\jpgraph\jpgraph-4.3.5\src\jpgraph_line.php');
require_once ('C:\wamp64\www\Projet\jpgraph\jpgraph-4.3.5\src\jpgraph_date.php');
$cxn= mysqli_connect("localhost","root","","piscineconnectee") or die ("error connecting to the server");
$query="SELECT HygroLocal,Heures FROM capteurs";
$res=mysqli_query($cxn,$query);
$hygro=[];
$heures=[];
while ($ligne=mysqli_fetch_assoc($res)){
array_push($heures, $ligne["Heures"]);
array_push($hygro, $ligne["HygroLocal"]);
}
// Setup the graph
$graph = new Graph(600,500);
$graph->SetScale("datlin");
$theme_class=new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Filled Y-grid');
$graph->SetBox(false);
$graph->SetMargin(40,20,36,63);
$graph->img->SetAntiAliasing();
$graph->xaxis->scale->SetDateFormat('H:i');
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');
// Create the first line
$p1 = new LinePlot($hygro, $heures);
$graph->Add($p1);
$p1->SetColor("#6495ED");
$p1->SetLegend('Line 1');
$graph->legend->SetFrameWeight(1);
// Output line
$graph->Stroke();
?> |
Partager