Code Gauge en php :
Température relevée le 31-10-18
à 10:44:04 Code gauge.php
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
<link href="../styles/style2.css" rel="stylesheet" type="text/css" />
<title>Code gauge</title>
</head>
<!-- You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
https://code.google.com/apis/ajax/playground/?type=visualization&hl=fr#gauge_interaction
-->
<body style="font-family: Arial;border: 0 none;">
<?php $Transfert = fopen('Transfert.txt', 'r+'); // Récupération des données dans les fichiers .txt
$Text = fgets($Transfert);
$Tpiscine = fgets($Transfert);
$pH= fgets($Transfert);
$date = fgets($Transfert);
$heure = fgets($Transfert);
fclose($Transfert);
$Ch = file_get_contents('Consigne_H.txt');
$Cb = file_get_contents('Consigne_B.txt');
$pH_H = file_get_contents('ConsignepH_H.txt');
$pH_B = file_get_contents('ConsignepH_B.txt');
if (isset($_POST['Ch'])&&($_POST['Ch']>$Cb)) {
$ConsigneH = fopen('Consigne_H.txt', 'r+');
ftruncate($ConsigneH,0);
$Ch = $_POST['Ch'];
//echo "<p>Consigne Haute ".$Ch."</p>";
ftruncate($ConsigneH,0);
fputs($ConsigneH,$Ch);
fclose($ConsigneH);}
if (isset($_POST['Cb'])&&($_POST['Cb']<$Ch)) {
$ConsigneB = fopen('Consigne_B.txt', 'r+');
ftruncate($ConsigneB,0);
$Cb = $_POST['Cb'];
//echo "<p>Consigne Basse ".$Cb."</p>";
ftruncate($ConsigneB,0);
fputs($ConsigneB,$Cb);
fclose($ConsigneB);}
if (isset($_POST['pH_H'])&&($_POST['pH_H']>$pH_B)) {
$ConsigneH = fopen('ConsignepH_H.txt', 'r+');
ftruncate($ConsigneH,0);
$pH_H = $_POST['pH_H'];
//echo "<p>Consigne Haute ".$Ch."</p>";
ftruncate($ConsigneH,0);
fputs($ConsigneH,$pH_H);
fclose($ConsigneH);}
if (isset($_POST['pH_B'])&&($_POST['pH_B']<$pH_H)) {
$ConsigneB = fopen('ConsignepH_B.txt', 'r+');
ftruncate($ConsigneB,0);
$pH_B = $_POST['pH_B'];
//echo "<p>Consigne Basse ".$Cb."</p>";
ftruncate($ConsigneB,0);
fputs($ConsigneB,$pH_B);
fclose($ConsigneB);}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-47469387-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="//www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['gauge']});
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}
function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
</script>
<?php echo "<p>Température relevée le ".$date." à ".$heure." </p>"; ?>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var Tpiscine = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Piscine C',<?php echo $Tpiscine;?>]
]);
var pH = google.visualization.arrayToDataTable([
['Label', 'Value'],
['pH', <?php echo $pH;?>]
]);
var Text = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Ext. C', <?php echo $Text;?>]
]);
gaugeOptions1 = {
min: 15,
max:30,
greenFrom:<?php echo $Cb ?> , greenTo: <?php echo $Ch ?>,
minorTicks: 1,
};
gaugeOptions2 = {
min: 6,
max:9,
greenFrom:<?php echo $pH_B ?> , greenTo: <?php echo $pH_H ?> ,
minorTicks: 0.1,
};
gaugeOptions3 = {
min: 0,
max:40,
greenFrom: 25, greenTo: 30 ,
minorTicks: 5,
};
// Create and draw the visualization.
new google.visualization.Gauge(document.getElementById('gaugePiscine')).
draw(Tpiscine ,gaugeOptions1);
new google.visualization.Gauge(document.getElementById('gaugepH')).
draw(pH ,gaugeOptions2);
new google.visualization.Gauge(document.getElementById('gaugeText')).
draw(Text ,gaugeOptions1);
}
google.setOnLoadCallback(drawVisualization);
</script>
<table style="width: 100%">
<tr>
<td id="gaugePiscine" style="width: 250px; height: 250px; float: left;">
</td>
<td id="gaugepH" style="width: 250px; height: 200px; float: left;">
</td>
<td id="gaugeText" style="width: 250px; height: 250px; float: left;">
</td>
<td style="width: 394px; height: 250px; float: left;">
<a href="Pres_graphe.php" onclick="window.open(this.href); return false;">
Voir le graphe + code php</a> </a>
<p>Consigne haute :
<span style="font-weight: bold; color: red;"><?php echo $Ch ?>
°C </span></p>
<form action="pH_piscine.php" method="post">
<span style="color: red;">Consigne Haute </span>
<input name="Ch" style="color: red;" type="text" /><span style="color: red;">
°C</span> <input type="submit" value="Valider" /></form>
<p>Consigne basse :
<span style="font-weight: bold; color: blue;"><?php echo $Cb ?>
°C </span></p>
<form action="pH_piscine.php" method="post">
<span style="color: rgb(51, 102, 255);">Consigne Basse
</span>
<input name="Cb" style="color: rgb(51, 102, 255);" type="text" /><span style="color: rgb(51, 102, 255);">
°C</span> <input type="submit" value="Valider" /></form>
</td>
<td style="width: 394px; height: 250px; float: left;">
<a href="Pres_graphe.php" onclick="window.open(this.href); return false;">
Voir le graphe + code php</a> </a>
<p>Consigne pH haut : <span style="font-weight: bold; color: red;"><?php echo $pH_H ?></span>
</p>
<form action="pH_piscine.php" method="post">
<span style="color: red;">Consigne pH haut : </span>
<input name="pH_H" style="color: red;" type="text" /><input type="submit" value="Valider" /></form>
<p>Consigne pH basse :
<span style="font-weight: bold; color: blue;"><?php echo $pH_B ?></span></p>
<form action="pH_piscine.php" method="post">
<span style="color: rgb(51, 102, 255);">Consigne pH
basse :</span>
<input name="pH_B" style="color: rgb(51, 102, 255);" type="text" /><input type="submit" value="Valider" />
</form>
</td>
</tr>
</table>
</body>