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 75 76 77 78
|
<script>
var jour = [];
var temperaturematin = [];
</script>
while ( $NbJour2 <= $NbJour1 + 1)
{
$DateDebut2 = $DateDebut1 ->format('Y-m-d');
echo $DateDebut2;
echo "<br>";
$Requete1 = "SELECT MAX(`temperature`) FROM temperature WHERE (`date` = '".$DateDebut2."') and (`heure` between '08:00:00' and '12:00:00')";
$Retour1 = $bdd->query($Requete1);
$Resultat1 = $Retour1->fetch();
$TemperatureMatin1 = $Resultat1['MAX(`temperature`)'];
if ( $TemperatureMatin1 == '' )
{
$TemperatureMatin1 = 0;
}
echo $TemperatureMatin1;
echo
"
<script>
if ( nombrejour == 0)
{
jour[jour.length + 1] = '".$DateDebut2."' ;
temperaturematin[temperaturematin.length + 1] = \"".$TemperatureMatin1." \" ;
nombrejour = nombrejour + 1;
}
else if ( nombrejour >= 1)
{
jour[jour.length + 1] = '".$DateDebut2."' ;
temperaturematin[temperaturematin.length + 1] = \"".$TemperatureMatin1." \" ;
nombrejour = nombrejour + 1;
}
</script>
";
$DateDebut1 ->add(new DateInterval('P1D'));
$NbJour2 = $NbJour2 + 1;
}
<script>
new Chart(document.getElementById("graphique"), {
type: 'line',
data: {
labels: jour,
datasets: [{
data: temperaturematin,
label: "Temperature matin",
borderColor: "#3e95cd",
fill: true,
},
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
yAxes : [{
ticks : {
min : 0
}
}]
}
}
});
</script> |