fix main graph history slurping
[dweather.git] / templates / index.html.ep
index d54833ddb60467769593123512d9736da5c81ea7..cd8155ac915383febf006cc071da7048e00738d5 100644 (file)
@@ -21,9 +21,9 @@
                <script>
                var ws;
                var daychart;
-               var daychart_days = 5;
+               var daychart_days = <%= $main::histdays %>;
                var windrose;
-               var windrose_mins = 10;
+               var windrose_mins = <%= $main::windmins %>;
                var windspeed;
                var winddir;
 
@@ -85,7 +85,7 @@
                                                                        js.r.Dir = lastdir;
                                                                }
                                                                lastt = js.t;
-                                                               fill_windrose(js, windrose_mins * (60 / 2.5));
+                                                               fill_windrose(js, windrose_mins * 24);
 //                                                     }
                                                        fill_windspeed(js);
                                                        fill_winddir(js);
                                        floating: true,
                                        backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
                                },
+                               exporting: {
+                                       buttons: {
+                                               contextButton: {
+                                                       enabled: false
+                                               }
+                                       }
+                               }, 
                                series: [{
                                        name: 'Rainfall',
                                        type: 'column',
                                            <% $s = "";
                                                   for (@main::last5daysh) { 
                                                      my $r = $main::json->decode($_);
-                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Rain_1h} . "]," if $r;
+                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Rain_1h} . "]," if $r && exists $r->{t} && exists $r->{h}->{Rain_1h};
                                                   }
                                                   chop $s if length $s; 
                                                %><%= $s %>
                                                <% $s = "";
                                                   for (@main::last5daysh) { 
                                                      my $r = $main::json->decode($_);
-                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Pressure} . "]," if $r;
+                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Pressure} . "]," if $r && exists $r->{t} && exists $r->{h}->{Pressure};
                                                   }
                                                   chop $s if length $s; 
                                                %><%= $s %>
                                                <% $s = "";
                                                   for (@main::last5daysh) { 
                                                      my $r = $main::json->decode($_);
-                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Temp_Out} . "]," if $r;
+                                                     $s .=  "[" . $r->{t}*1000 . "," . $r->{h}->{Temp_Out} . "]," if $r && exists $r->{t} && exists $r->{h}->{Temp_Out};
                                                   }
                                                   chop $s if length $s; 
                                                %><%= $s %>
                                                groupPadding: 0
                                        }
                                },
+                               exporting: {
+                                       buttons: {
+                                               contextButton: {
+                                                       enabled: false
+                                               }
+                                       }
+                               }, 
 
                                series: [ {
-                                       type: 'scatter',
+                                       type: 'column',
                                        name: 'Wind mph',
                                        data: [
                                                <% my ($d, $w);
                                                          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;
+                                                                 $s .=  "[" . $r->{r}->{Dir} . "," . main::nearest(0.1, $r->{r}->{Wind}*2.23694) . "],";
                                                                  $d = $r->{r}->{Dir};
                                                                  $w = $r->{r}->{Wind};
                                                          }
                                                color: '#DF5353' // red
                                        }]
                                },
+                               exporting: {
+                                       buttons: {
+                                               contextButton: {
+                                                       enabled: false
+                                               }
+                                       }
+                               }, 
 
                                series: [{
                                        name: 'Speed',
                                                text:  '° deg'
                                        },
                                },
+                               exporting: {
+                                       buttons: {
+                                               contextButton: {
+                                                       enabled: false
+                                               }
+                                       }
+                               }, 
 
                                series: [{
                                        name: 'Direction',