Commit 0071f5d7df2686c1663c5c893515f2d69071e034
1 parent
ee41974f
MAJ
Showing
4 changed files
with
24 additions
and
11 deletions
Show diff stats
site/accesBase.php
... | ... | @@ -282,5 +282,15 @@ |
282 | 282 | $array[] = $element[$column]; |
283 | 283 | } |
284 | 284 | return $array; |
285 | - } | |
285 | + } | |
286 | + | |
287 | + function getLegend($nom) | |
288 | + { | |
289 | + $db = connexion(); | |
290 | + $query = "SELECT type, unite FROM capteurs WHERE nom = '$nom'"; | |
291 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | |
292 | + $tab = pg_fetch_assoc($result); | |
293 | + deconnexion($db); | |
294 | + return $tab; | |
295 | + } | |
286 | 296 | ?> | ... | ... |
site/formGraphe.php
... | ... | @@ -10,7 +10,7 @@ $date_max = $maxs[0]; |
10 | 10 | <div class="row"> |
11 | 11 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
12 | 12 | <br/> |
13 | - <h1 style="margin-bottom:20px; margin-top:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Affichage un graphe</h1> | |
13 | + <h1 style="margin-bottom:20px; margin-top:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Affichage d'un graphe</h1> | |
14 | 14 | <form action="graphique.php" method="post"> |
15 | 15 | <table class="table table-striped table-bordered"> |
16 | 16 | <tbody> |
... | ... | @@ -41,8 +41,8 @@ $date_max = $maxs[0]; |
41 | 41 | </tr> |
42 | 42 | |
43 | 43 | <tr> |
44 | - <td><label for"nombre">Nombre de points (entre 4 et 100) :</label></td> | |
45 | - <td><input type="text" id="nombre" name="nombre" min="4" max="100" value="4" /></td> | |
44 | + <td><label for"nombre">Nombre de points :</label></td> | |
45 | + <td><input type="text" id="nombre" name="nombre" min="2" max="25" value="10" /></td> | |
46 | 46 | </tr> |
47 | 47 | </tbody> |
48 | 48 | </table> | ... | ... |
site/graphe.php
... | ... | @@ -3,6 +3,7 @@ require_once ('jpgraph/jpgraph.php'); |
3 | 3 | require_once ('jpgraph/jpgraph_line.php'); |
4 | 4 | require_once('accesBase.php'); |
5 | 5 | |
6 | +$legend = getLegend($_REQUEST['nom']); | |
6 | 7 | $history = getHistory($_REQUEST['nom'], '', '', $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['nombre']); |
7 | 8 | $y = makeArray($history, "value"); |
8 | 9 | $x = makeArray($history, "date"); |
... | ... | @@ -11,7 +12,7 @@ $datay = array_reverse($y); |
11 | 12 | $datax = array_reverse($x); |
12 | 13 | |
13 | 14 | // Setup the graph |
14 | -$graph = new Graph(800,400); | |
15 | +$graph = new Graph(1100,400); | |
15 | 16 | $graph->SetScale("textlin"); |
16 | 17 | |
17 | 18 | $theme_class=new UniversalTheme; |
... | ... | @@ -21,36 +22,38 @@ $graph->img->SetAntiAliasing(false); |
21 | 22 | $graph->title->Set('Capteur '.$_REQUEST['nom']); |
22 | 23 | $graph->SetBox(false); |
23 | 24 | |
24 | -$graph->SetMargin(40,30,40,50); | |
25 | +$graph->SetMargin(40,30,40,150); | |
25 | 26 | |
26 | 27 | $graph->img->SetAntiAliasing(); |
27 | 28 | |
28 | 29 | $graph->yaxis->HideZeroLabel(); |
29 | 30 | $graph->yaxis->HideLine(false); |
30 | 31 | $graph->yaxis->HideTicks(false,false); |
32 | +$graph->yaxis->title->Set($legend['type']."(".$legend['unite'].")"); | |
31 | 33 | |
32 | 34 | $graph->xgrid->Show(); |
33 | 35 | $graph->xgrid->SetLineStyle("solid"); |
34 | 36 | $graph->xaxis->SetTickLabels($datax); |
37 | +$graph->xaxis->SetLabelAngle(80); | |
35 | 38 | $graph->xgrid->SetColor('#E3E3E3'); |
36 | 39 | |
37 | 40 | // Create the line |
38 | 41 | $p = new LinePlot($datay); |
39 | 42 | $graph->Add($p); |
40 | -$p->SetColor("#6495ED"); | |
43 | +$p->SetColor('#5c0f10'); | |
41 | 44 | |
42 | 45 | // Afficher les valeurs pour chaque point |
43 | 46 | $p->value->Show(); |
44 | 47 | |
45 | 48 | // Valeurs: Apparence de la police |
46 | 49 | $p->value->SetFormat('%.1f'); |
47 | -$p->value->SetColor("red"); | |
50 | +$p->value->SetColor('#0c0f52'); | |
48 | 51 | |
49 | 52 | // Chaque point de la courbe **** |
50 | 53 | // Type de point |
51 | 54 | $p->mark->SetType(MARK_FILLEDCIRCLE); |
52 | 55 | // Couleur de remplissage |
53 | -$p->mark->SetFillColor("green"); | |
56 | +$p->mark->SetFillColor('#0D0D0D'); | |
54 | 57 | // Taille |
55 | 58 | $p->mark->SetWidth(5); |
56 | 59 | ... | ... |
site/graphique.php
... | ... | @@ -25,9 +25,9 @@ else $start = $start." 00:00:00"; |
25 | 25 | { |
26 | 26 | ?> |
27 | 27 | <div class="row"> |
28 | - <div class="col-8 col-md-8 offset-md-2 offset-2"> | |
28 | + <div class="col-10 col-md-10 offset-md-1 offset-1"> | |
29 | 29 | <br/> |
30 | - <h1 style="margin-bottom:20px; margin-top:30px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Graphe du capteur</h1> | |
30 | + <h1 style="margin-bottom:20px; margin-top:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Graphe du capteur</h1> | |
31 | 31 | <?php |
32 | 32 | echo "<img src='graphe.php?nom=$nom&nombre=$nombre&start=$start&end=$end' alt='graphe'>"; |
33 | 33 | ?> | ... | ... |