update legend when updateOptions() is called
authorDan Vanderkam <dan@dygraphs.com>
Sun, 10 Apr 2011 19:13:29 +0000 (15:13 -0400)
committerDan Vanderkam <dan@dygraphs.com>
Sun, 10 Apr 2011 19:13:29 +0000 (15:13 -0400)
dygraph.js

index 4227652..958d1f3 100644 (file)
@@ -1811,7 +1811,6 @@ Dygraph.prototype.setSelection = function(row) {
     this.lastx_ = this.selPoints_[0].xval;
     this.updateSelection_();
   } else {
-    this.lastx_ = -1;
     this.clearSelection();
   }
 
@@ -2630,6 +2629,13 @@ Dygraph.prototype.drawGraph_ = function() {
   if (is_initial_draw) {
     // Generate a static legend before any particular point is selected.
     this.attr_('labelsDiv').innerHTML = this.generateLegendHTML_();
+  } else {
+    if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) {
+      this.lastx_ = this.selPoints_[0].xval;
+      this.updateSelection_();
+    } else {
+      this.clearSelection();
+    }
   }
 
   if (this.attr_("drawCallback") !== null) {