Remove duplicated layout/range selector initialization code
[dygraphs.git] / dygraph.js
index ed021cd..d9997e9 100644 (file)
@@ -43,6 +43,8 @@
 
  */
 
+"use strict";
+
 /**
  * Creates an interactive, zoomable chart.
  *
@@ -57,7 +59,7 @@
  * whether the input data contains error ranges. For a complete list of
  * options, see http://dygraphs.com/options.html.
  */
-Dygraph = function(div, data, opts) {
+var Dygraph = function(div, data, opts) {
   if (arguments.length > 0) {
     if (arguments.length == 4) {
       // Old versions of dygraphs took in the series labels as a constructor
@@ -812,14 +814,6 @@ Dygraph.prototype.createInterface_ = function() {
     this.rangeSelector_.addToGraph(this.graphDiv, this.layout_);
   }
 
-  // Create the grapher
-  this.layout_ = new DygraphLayout(this);
-
-  if (this.rangeSelector_) {
-    // This needs to happen after the graph canvases are added to the div and the layout object is created.
-    this.rangeSelector_.addToGraph(this.graphDiv, this.layout_);
-  }
-
   var dygraph = this;
   Dygraph.addEvent(this.mouseEventElement_, 'mousemove', function(e) {
     dygraph.mouseMove_(e);
@@ -1937,8 +1931,10 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) {
 
     if (bars) {
       for (var j=0; j<series.length; j++) {
-        val = [series[j][0], series[j][1][0], series[j][1][1], series[j][1][2]];
-        series[j] = val;
+        series[j] = [series[j][0],
+                     series[j][1][0],
+                     series[j][1][1],
+                     series[j][1][2]];
       }
     } else if (this.attr_("stackedGraph")) {
       var l = series.length;
@@ -3202,4 +3198,4 @@ Dygraph.addAnnotationRule = function() {
 }
 
 // Older pages may still use this name.
-DateGraph = Dygraph;
+var DateGraph = Dygraph;