don't draw plot w/o data
authorEugene Crosser <crosser@average.org>
Thu, 4 Feb 2016 21:49:53 +0000 (00:49 +0300)
committerEugene Crosser <crosser@average.org>
Thu, 4 Feb 2016 21:49:53 +0000 (00:49 +0300)
web/index.html

index 9181b7963ac0e6f56b1458549282b035278d760e..7c0b4a4af3c9554e27d316fd47732226cd6eb8b3 100644 (file)
   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() {