Make setSelection() work with missing points.
[dygraphs.git] / dygraph.js
index 8a0ee08..1745f05 100644 (file)
@@ -280,7 +280,6 @@ Dygraph.DEFAULT_ATTRS = {
   customBars: false,
   fillGraph: false,
   fillAlpha: 0.15,
-  fillStepPlot: false,
   connectSeparatedPoints: false,
 
   stackedGraph: false,
@@ -1105,6 +1104,7 @@ Dygraph.prototype.createInterface_ = function() {
 
   // TODO(danvk): any other styles that are useful to set here?
   this.graphDiv.style.textAlign = 'left';  // This is a CSS "reset"
+  this.graphDiv.style.position = 'relative';
   enclosing.appendChild(this.graphDiv);
 
   // Create the canvas for interactive parts of the chart.
@@ -2124,10 +2124,14 @@ Dygraph.prototype.setSelection = function(row, opt_seriesName, opt_locked) {
     this.lastRow_ = row;
     for (var setIdx = 0; setIdx < this.layout_.points.length; ++setIdx) {
       var points = this.layout_.points[setIdx];
-      var setRow = row - this.getLeftBoundary_(setIdx);
-      if (setRow < points.length) {
-        var point = points[setRow];
-        if (point.yval !== null) this.selPoints_.push(point);
+      for (var pointIdx = 0; pointIdx < points.length; ++pointIdx) {
+       var point = points[pointIdx];
+        if (point.idx == row) {
+          if (point.yval !== null) {
+            this.selPoints_.push(point);
+          }
+          break;
+        }
       }
     }
   } else {