added tips, and fixed loading and nodata divs
authorAndrew Tridgell <tridge@samba.org>
Mon, 11 Oct 2010 23:43:53 +0000 (10:43 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 11 Oct 2010 23:43:53 +0000 (10:43 +1100)
live/graphs.js
live/index.html

index 415a724cecf79b86858b15ce3d9060f88699676b..8e2200abd2970a191dc1c73a7457494fa002a890 100644 (file)
@@ -58,7 +58,9 @@ function loading(busy) {
       hide_div("loading", false);
     }
   } else {
-    loading_counter--;
+    if (loading_counter > 0) {
+      loading_counter--;
+    }
     if (loading_counter == 0) {
       hide_div("loading", true);
     }
@@ -136,15 +138,25 @@ function load_CSV(filename, callback) {
     if (CSV_Cache[filename].pending) {
       /* its pending load by someone else. Add ourselves to the notify
         queue so we are told when it is done */
+      writeDebug("waiting on: " + filename);
       CSV_Cache[filename].queue.push({filename:filename, callback:callback});
       return;
     }
 
     /* its ready in the cache - return it via a delayed callback */
-    var d = { filename: CSV_Cache[filename].filename,
-             labels:   CSV_Cache[filename].labels.slice(0),
-             data:     CSV_Cache[filename].data.slice(0) };
-    queue_call(callback, d);
+    if (CSV_Cache[filename].data == null) {
+      var d = { filename: CSV_Cache[filename].filename,
+               labels:   null,
+               data:     null };
+      hide_div("nodata", false);
+      queue_call(callback, d);
+    } else {
+      var d = { filename: CSV_Cache[filename].filename,
+               labels:   CSV_Cache[filename].labels.slice(0),
+               data:     CSV_Cache[filename].data.slice(0) };
+      hide_div("nodata", true);
+      queue_call(callback, d);
+    }
     return;
   }
 
@@ -212,8 +224,12 @@ function load_CSV(filename, callback) {
     if (caller.r.readyState == 4) {
       if (caller.r.status == 200) {
        load_CSV_callback(caller);
+       hide_div("nodata", true);
+       writeDebug("got file: " + caller.filename);
       } else {
        /* the load failed */
+       writeDebug("missed file: " + caller.filename);
+       hide_div("nodata", false);
        queue_call(caller.callback, { filename: filename, data: null, labels: null });
        while (CSV_Cache[caller.filename].queue.length > 0) {
          var qe = CSV_Cache[caller.filename].queue.shift();
@@ -224,6 +240,8 @@ function load_CSV(filename, callback) {
        }
        CSV_Cache[caller.filename].pending = false;
        CSV_Cache[caller.filename].queue   = null;
+       CSV_Cache[caller.filename].data   = null;
+       CSV_Cache[caller.filename].labels   = null;
       }
     }
   }
@@ -303,6 +321,7 @@ function get_csv_data(filenames, columns, callback) {
     var labels = new Array();
 
     if (d.data == null) {
+      writeDebug("null data in process_one_csv");
       queue_call(caller.callback, d);
       return;
     }
@@ -380,7 +399,7 @@ global_graphs = new Array();
 defaultAttrs = {
  width: 700,
  height: 350,
- rollPeriod: 5,
+ rollPeriod: 1,
  strokeWidth: 1,
  showRoller: true
 }
@@ -412,7 +431,6 @@ function graph_csv_files_func(divname, filenames, columns, func1, func2, attrs)
 
     if (d[0] == undefined) {
       writeDebug("unable to load file");
-      /* hide_div("nodata", false); */
       loading(false);
       return;
     }
@@ -542,8 +560,6 @@ in_redraw = false;
  */
 function show_graphs() {
 
-  hide_div("nodata", true);
-
   graph_sum_csv_files("Total AC Power (W)",
                      days_csv_files(),
                       "Pac",
index 91a1bed60362acfcbe9d8589f6ce27392c02805e..fc7df038d827014698064d0a9d2496bf4aa3314c 100755 (executable)
@@ -35,9 +35,21 @@ graphing package. Please be patient, or install Firefox</p>
 <![endif]-->
 
 
+<p>Tips:
+<ul>
+<li>You can zoom a time range by dragging the mouse over the range you
+  are interested in.</li>
+<li>Double click to see the whole data set again.</li>
+<li>You can change the rolling average value using the selection box
+  in the bottom left corner of each graph.
+<li>Use the green +/- icons to hide or show a particular graph
+</ul>
+</p>
+
+
 <form id="dateForm" method="get" onsubmit="return false;" action="">
     <fieldset>
-      <p><input type="text" class="w8em format-d-m-y highlight-days-67
+      <p>Select Date: <input type="text" class="w8em format-d-m-y highlight-days-67
       range-high-today range-low-2010-10-09" name="pvdate" id="pvdate" value="" maxlength="10" /></p>
     </fieldset>
 </form>