Fixed attribute name typo in legend follow (#792)
[dygraphs.git] / src / plugins / range-selector.js
index 2090fae..7f91dc8 100644 (file)
@@ -15,6 +15,7 @@
 
 import * as utils from '../dygraph-utils';
 import DygraphInteraction from '../dygraph-interaction-model';
+import IFrameTarp from '../iframe-tarp';
 
 var rangeSelector = function() {
   this.hasTouchInterface_ = typeof(TouchEvent) != 'undefined';
@@ -256,7 +257,7 @@ rangeSelector.prototype.initInteraction_ = function() {
 
   // We cover iframes during mouse interactions. See comments in
   // dygraph-utils.js for more info on why this is a good idea.
-  var tarp = new utils.IFrameTarp();
+  var tarp = new IFrameTarp();
 
   // functions, defined below.  Defining them this way (rather than with
   // "function foo() {...}" makes JSHint happy.
@@ -634,13 +635,23 @@ rangeSelector.prototype.computeCombinedSeriesAndLimits_ = function() {
   var labels = g.getLabels();
   var includeSeries = new Array(numColumns);
   var anySet = false;
+  var visibility = g.visibility();
+  var inclusion = [];
+
   for (i = 1; i < numColumns; i++) {
     var include = this.getOption_('showInRangeSelector', labels[i]);
-    includeSeries[i] = include;
+    inclusion.push(include);
     if (include !== null) anySet = true;  // it's set explicitly for this series
   }
-  if (!anySet) {
-    for (i = 0; i < includeSeries.length; i++) includeSeries[i] = true;
+
+  if (anySet) {
+    for (i = 1; i < numColumns; i++) {
+      includeSeries[i] = inclusion[i - 1];
+    }
+  } else {
+    for (i = 1; i < numColumns; i++) {
+      includeSeries[i] = visibility[i - 1];
+    }
   }
 
   // Create a combined series (average of selected series values).