]> www.average.org Git - pulsecounter.git/blobdiff - web/index.html
don't draw plot w/o data
[pulsecounter.git] / web / index.html
index ca76aaa0790126569a0286a671fab3aa9eb1e9c3..7c0b4a4af3c9554e27d316fd47732226cd6eb8b3 100644 (file)
@@ -56,7 +56,7 @@
     else { /* ~ one month */
       /* TODO: make this a separate case with loop over months rather than
          fixed number of seconds. */
-      inc = 2592000;
+      inc = 86400;
       inc2 = 2592000;
       label = tomonth;
     }
   function drawplot(data, color) {
     var i;
 
-    ctx.beginPath();
-    ctx.moveTo(px(data[0][0]), py(data[0][1]));
-    for (i = 1; i < data.length; i++) {
-      ctx.lineTo(px(data[i][0]), py(data[i - 1][1]));
-      ctx.lineTo(px(data[i][0]), py(data[i][1]));
+    if (data.length) {
+      ctx.beginPath();
+      ctx.moveTo(px(data[0][0]), py(data[0][1]));
+      for (i = 1; i < data.length; i++) {
+        ctx.lineTo(px(data[i][0]), py(data[i - 1][1]));
+        ctx.lineTo(px(data[i][0]), py(data[i][1]));
+      }
+      ctx.strokeStyle = color;
+      ctx.stroke();
     }
-    ctx.strokeStyle = color;
-    ctx.stroke();
   }
 
   function showloading() {