Fix bugs in connectSeparatedPoints implementation. Add test.
authorAdam Vartanian <flooey@google.com>
Mon, 8 Mar 2010 20:44:06 +0000 (15:44 -0500)
committerAdam Vartanian <flooey@google.com>
Mon, 8 Mar 2010 20:44:06 +0000 (15:44 -0500)
dygraph.js
tests/connect-separated.html [new file with mode: 0644]

index 6aa6bf4..4b9b6f1 100644 (file)
@@ -958,7 +958,7 @@ Dygraph.prototype.updateSelection_ = function() {
         replace += "<br/>";
       }
       var point = this.selPoints_[i];
-      var c = new RGBColor(this.plotter_.colors_[point.name]);
+      var c = new RGBColor(this.plotter_.colors[point.name]);
       replace += " <b><font color='" + c.toHex() + "'>"
               + point.name + "</font></b>:"
               + this.round_(point.yval, 2);
@@ -970,7 +970,7 @@ Dygraph.prototype.updateSelection_ = function() {
     for (var i = 0; i < this.selPoints_.length; i++) {
       if (!isOK(this.selPoints_[i].canvasy)) continue;
       ctx.beginPath();
-      ctx.fillStyle = this.plotter_.colors_[this.selPoints_[i].name];
+      ctx.fillStyle = this.plotter_.colors[this.selPoints_[i].name];
       ctx.arc(canvasx, this.selPoints_[i].canvasy, circleSize,
               0, 2 * Math.PI, false);
       ctx.fill();
@@ -1486,7 +1486,7 @@ Dygraph.prototype.drawGraph_ = function(data) {
     for (var j = 0; j < data.length; j++) {
       if (data[j][i] || !connectSeparatedPoints) {
         var date = data[j][0];
-        series[j] = [date, data[j][i]];
+        series.push([date, data[j][i]]);
       }
     }
     series = this.rollingAverage(series, this.rollPeriod_);
diff --git a/tests/connect-separated.html b/tests/connect-separated.html
new file mode 100644 (file)
index 0000000..5993375
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+  <head>
+    <title>connect separated</title>
+    <!--[if IE]>
+    <script type="text/javascript" src="excanvas.js"></script>
+    <![endif]-->
+    <script type="text/javascript" src="../dygraph-combined.js"></script>
+    <script type="text/javascript" src="../dygraph-canvas.js"></script>
+    <script type="text/javascript" src="../dygraph.js"></script>
+  </head>
+  <body>
+    <p>Connecting separated points.  All three of the series should have their points
+      connected with lines, and hovering over them should produce dot and legend
+      overlays in the proper color.</p>
+      
+    <div id="graphdiv" style="width:600px; height:300px;"></div>
+    <script type="text/javascript">
+      new Dygraph(document.getElementById("graphdiv"),
+      [
+        [ new Date("2009/12/01"), 10, 10, 10],
+        [ new Date("2009/12/02"), 15, 11, 12],
+        [ new Date("2009/12/03"), null, null, 12],
+        [ new Date("2009/12/04"), 20, 14, null],
+        [ new Date("2009/12/05"), 15, null, 17],
+        [ new Date("2009/12/06"), 18, null, 16],
+        [ new Date("2009/12/07"), 12, 14, 19]
+      ],
+      {
+        connectSeparatedPoints: true,
+        labels: ["Date","Series1","Series2","Series3"],
+      });
+    </script>
+  </body>
+</html>