As I told you, my data is extracted from a database.
On a table I retrieve the average temperature and the date. On another table I get the normal average temperatures.
This graph compares the difference between the average temperature and the normal average temperature over a full year from January 1 to December 31. Here is an example of a full year, the year 2021. I would like my graph to look like this example.
https://www.meteo-jarny.com/test/graph-test9.php
As you can see, there is no error 15 because the two series average temperature, normal average temperature and the dates have the same length, ie 365 days.
The problem arises on the current year because I retrieve the normal average temperatures on my table (365 days) and the average temperature and the date on another table which stops at February 28 on this example.
https://jsfiddle.net/JP5401/rj7qm8ew/12/
Until I get the full year, I'll get error 15. And I don't know how to get around this problem.
I give you the PHP part of my graph with which I retrieve my data on my tables, it may help you to understand better
Code: Select all
$query=mysqli_query($conn,$sql);
$list=mysqli_fetch_array($query);
$start = mktime(0,0,0,1,1,date("2021"));
$stop = mktime(23,59,59,12,31,date("2021"));
$sql = "SELECT tstamp, temp_moy FROM minimaxiarchive WHERE ((tstamp) between '$start' AND '$stop') ";
$query=mysqli_query($conn,$sql);
$i=0;
while ($list = mysqli_fetch_assoc($query)) {
$dtime[$i] = $list['tstamp']*1000;
$dmean[$i]=$list['temp_moy']*1;
$i++;
}
$sql = "SELECT jour, mois, norme_temp_moy FROM normale_journaliere_365 ";
$query=mysqli_query($conn,$sql);
$i=0;
while ($list = mysqli_fetch_assoc($query)) {
$dnorme[$i]=$list['norme_temp_moy']*1;
$ecart[$i] = $dmean[$i] - $dnorme[$i];
$i++;
}
mysqli_close($conn);
?>