$premo = $ysign == $actrY ? $actrM * 1 : 12; // We have in this year also data from 1.1. of next year so we use $ysign // NEXT DAY sign $chDay = $actDay; } // CREATE ARRAYS FOR JS DATA CALCULATION $aTemp[] = convcf($row['temperature']); $aDP[] = convcf($row['dew_point_temperature']); $aHum[] = $row['outdoor_humidity']; $aBaro[] = round($row['barometer'] * $r_baro, 2); $aWS[] = round($row['average_windspeed'] * $r_wind, 1); $agWS[] = round($row['gust_windspeed'] * $r_wind, 1); $awindir[] = $row['wind_direction']; $aSolar[] = $row['actual_solar_reading']; $aUV[] = $row['davis_vp_uv']; $aIndTemp[] = convcf($row['indoor_temperature']); $dailyRain = $row['daily_rainfall']; // yesterday_rainfall system is a little bit problematic $pdtstamp = strtotime(substr($row['datetime'], 0, 10) . ' 00:00:00') * 1000; //js timestamp; substr is for time correction $actrM = substr($row['datetime'], 5, 2); $actrY = substr($row['datetime'], 0, 4); } date_default_timezone_set($TZconf); // Back to configured timezone // FINISH DAYS RAIN DATA TO MONTH - last month $rainC .= "[" . $premo . ',' . $monthrSum . "],"; $rainS += $monthrSum; $rainT .= "[" . $premo . ',' . $rainS . "],"; if (mysql_affected_rows() < 2) { // we need at least two values for drawing a line in graph.
//Proceed data while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { $dTimeArray .= strtotime($row['datetime']) * 1000 . ','; $dTemp .= convcf($row['temperature']) . ','; $dDP .= convcf($row['dew_point_temperature']) . ','; $dBaro .= round($row['barometer'] * $r_baro, 2) . ','; $dWindDir .= $row['wind_direction'] . ','; $dAvgWS .= round($row['average_windspeed'] * $r_wind * $windcon, 1) . ','; $dGustWS .= round($row['gust_windspeed'] * $r_wind * $windcon, 1) . ','; $dHum .= $row['outdoor_humidity'] . ','; $dRainSpd .= round($row['rain_rate'] * $r_rate, 2) . ','; $dRainT .= round($row['daily_rainfall'] * $r_rain, 2) . ','; $dSolar .= $row['actual_solar_reading'] . ','; $dCond .= '"' . str_replace('_', ' ', $row['current_weather_desc']) . '",'; $dUV .= $row['davis_vp_uv'] . ','; $dIndTemp .= convcf($row['indoor_temperature']) . ','; } date_default_timezone_set($TZconf); // Back to configured timezone if (mysql_affected_rows() < 2) { // we need at least two values for drawing a line in graph. $emptyGraph = true; } // metric/imperial units conversion for spike correcting $baroSpike = $metric ? 1 : 33.86; $tempSpike = $metric ? 1 : 1.8; $rainSpike = $metric ? 1 : 2.54; $windSpike = $metric ? 1 : 0.6214; $outData = 'var dTemp = [' . rmSpike(substr($dTemp, 0, -1), $dsp['temp'] * $tempSpike) . ']; var dDP = [' . rmSpike(substr($dDP, 0, -1), $dsp['temp'] * $tempSpike) . ']; var dBaro = [' . rmSpike(substr($dBaro, 0, -1), $dsp['baro'] / $baroSpike) . '];
$chwindSpd[] = $value; //only for bad value comparsion break; case 2: $windGst[] = mxround($value * $mwind * $windcon, 1); $chwindGst[] = $value; //only for bad value comparsion break; case 3: $windDir[] = $value; $chwindDir[] = $value; //only for bad value comparsion break; case 4: # print_r($temp); exit; $temp[] = convcf($value); $chtemp[] = $value; // ... break; case 5: $humi[] = $value; $chhumi[] = $value; break; case 6: $baro[] = mxround($value * $mbaro, 2); $chbaro[] = $value; break; case 7: $rain[] = mxround($value * $mrain, 2); $chrain[] = $value; break;