$c->send($ld->{lasthour_h}) if exists $ld->{lasthour_h};
$c->send($ld->{lastmin_h}) if exists $ld->{lastmin_h};
- # send the 5 days worth of data to the graph
- say "last10min = " . scalar @last10minsr . " last5day = " . scalar @last5daysh;
- $c->send($_) for @last10minsr;
- $c->send($_) for @last5daysh;
-
# disable timeout
$c->inactivity_timeout(3615);
% my $url = url_for 'weather';
+% my $s;
<!DOCTYPE html>
<html>
<head>
name: 'Rainfall',
type: 'column',
yAxis: 1,
- data: [],
+ data: [
+ <% $s = "";
+ for (@main::last5daysh) {
+ my $r = $main::json->decode($_);
+ $s .= "[" . $r->{t}*1000 . "," . $r->{h}->{Rain_1h} . "]," if $r;
+ }
+ chop $s if length $s;
+ %><%= $s %>
+ ],
tooltip: {
valueSuffix: ' mm'
}
name: 'Sea-Level Pressure',
type: 'spline',
yAxis: 2,
- data: [],
+ data: [
+ <% $s = "";
+ for (@main::last5daysh) {
+ my $r = $main::json->decode($_);
+ $s .= "[" . $r->{t}*1000 . "," . $r->{h}->{Pressure} . "]," if $r;
+ }
+ chop $s if length $s;
+ %><%= $s %>
+ ],
marker: {
enabled: false
},
}, {
name: 'Temperature',
type: 'spline',
- data: [],
+ data: [
+ <% $s = "";
+ for (@main::last5daysh) {
+ my $r = $main::json->decode($_);
+ $s .= "[" . $r->{t}*1000 . "," . $r->{h}->{Temp_Out} . "]," if $r;
+ }
+ chop $s if length $s;
+ %><%= $s %>
+ ],
tooltip: {
valueSuffix: ' °C'
}
series: [ {
type: 'scatter',
name: 'Wind mph',
- data: []
+ data: [
+ <% my ($d, $w);
+ $s = "";
+ $d = 0; $w = 0;
+ for (@main::last10minsr) {
+ my $r = $main::json->decode($_);
+ if ($r) {
+ $r->{r}->{Dir} ||= $d;
+ $r->{r}->{Wind} ||= $w;
+ $s .= "[" . $r->{r}->{Dir} . "," . main::nearest(0.1, $r->{r}->{Wind}*2.23694) . "]," if $r;
+ $d = $r->{r}->{Dir};
+ $w = $r->{r}->{Wind};
+ }
+ }
+ chop $s if length $s;
+ %><%= $s %>
+ ]
}]
});
}