better averaging
authorAndrew Tridgell <tridge@samba.org>
Sat, 16 Oct 2010 07:49:16 +0000 (18:49 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sat, 16 Oct 2010 07:49:16 +0000 (18:49 +1100)
live/graphs.js
live/index.html

index cd21f8a0b0ffb09fb0f5b3082097406ddefb7afb..68786bf4291b717e61fddd082411991474fa2c24 100644 (file)
@@ -60,6 +60,7 @@ function canberraDate() {
  */
 pvdate = date_round(new Date());
 period_days = 1;
+auto_averaging = 1;
 tz_difference = 11 + (pvdate.getTimezoneOffset()/60);
 
 
@@ -860,6 +861,16 @@ function graph_csv_files_func(divname, filenames, columns, func1, func2, attrs)
        }
     }
 
+    var max_points = 900;
+    if (is_IE) {
+      max_points = 100;
+    }
+    if (auto_averaging) {
+      if (d2.data != null && (d2.data.length/defaultAttrs.averaging) > max_points) {
+       set_averaging(Math.round(0.5+(d2.data.length / max_points)));
+      }
+    }
+
     var avg_data = average_data(d2.data, defaultAttrs.averaging);
 
     /* create a new dygraph */
@@ -1078,19 +1089,11 @@ function toggle_div(divname)
   change display period
  */
 function change_period(p) {
+  p = +p;
   if (period_days != p) {
-    period_days = +p;
-    if (period_days == 1) {
-      if (is_IE) {
-       set_averaging(10);
-      } else {
-       set_averaging(1);
-      }
-    } else if (period_days == 7) {
-      set_averaging(15);
-    } else if (period_days >= 30) {
-      set_averaging(60);
-    }
+    period_days = p;
+    auto_averaging = 1;
+    set_averaging(1);
     show_graphs();
   }
 }
@@ -1101,6 +1104,7 @@ function change_period(p) {
 function change_averaging() {
   var v = +document.getElementById('averaging').value;
   defaultAttrs.averaging = v;
+  auto_averaging = 0;
   show_graphs();
 }
 
index dbbb7ca0126f577d71762c8a174c3d93f25ee5d9..c618da305a9d915201fd55d1a1ca898c26ada51b 100755 (executable)
@@ -31,9 +31,9 @@
 
 <!--[if IE]>
 <p>Note! You are using Internet Explorer to view this site. Internet
-explorer is very slow at displaying the canvas widgets used by the dygraphs
-graphing package, so you are being shown an average over 10 minutes
-for each point. For full data use Firefox or Chrome.</p>
+explorer is very slow at displaying the canvas widgets used by the
+dygraphs graphing package, so you are being shown the data at a lower
+resolution. For full data use Firefox or Chrome.</p>  
 <![endif]-->
 
 
@@ -71,19 +71,10 @@ if (hashvars['date'] != undefined) {
 } else {
   pvdate = canberraDate();
 }
-if (is_IE) {
-  set_averaging(10);
-} else {
-  set_averaging(1);
-}
 serialnums = [ 2001551093, 2001511859, 2001551109, 2001559615, 2001512099, 2001511912 ];
 CSV_directory = "../CSV/";
 setup_datepicker();
 show_graphs();
-if (!is_IE) {
-  /* IE is too slow to do reloads with excanvas */
-  setup_reload_timer();
-}
 </script>
 
 <p>