Fix responsese to code review 194.
[dygraphs.git] / dygraph.js
index 2bccd60..616fb31 100644 (file)
@@ -282,6 +282,8 @@ Dygraph.DEFAULT_ATTRS = {
     Dygraph.Plotters.linePlotter
   ],
 
+  plugins: [ ],
+
   // per-axis options
   axes: {
     x: {
@@ -452,8 +454,9 @@ Dygraph.prototype.__init__ = function(div, file, attrs) {
 
   // Activate plugins.
   this.plugins_ = [];
-  for (var i = 0; i < Dygraph.PLUGINS.length; i++) {
-    var Plugin = Dygraph.PLUGINS[i];
+  var plugins = Dygraph.PLUGINS.concat(this.getOption('plugins'));
+  for (var i = 0; i < plugins.length; i++) {
+    var Plugin = plugins[i];
     var pluginInstance = new Plugin();
     var pluginDict = {
       plugin: pluginInstance,
@@ -2452,23 +2455,13 @@ Dygraph.prototype.computeYAxes_ = function() {
     this.axes_[axis] = opts;
   }
 
-  // TODO(konigsberg): REMOVE THIS SILLINESS this should just come from DygraphOptions.
-  // TODO(konigsberg): Add tests for all of these.
-
-  // all options which could be applied per-axis:
-  var axisOptions = [
-    'valueRange',
-    'pixelsPerYLabel',
-    'axisLabelFontSize',
-  ];
 
-  // Copy global axis options over to the first axis.
-  for (i = 0; i < axisOptions.length; i++) {
-    var k = axisOptions[i];
-    v = this.attr_(k);
-    if (v) this.axes_[0][k] = v;
-  }
-  // TODO(konigsberg): end of REMOVE THIS SILLINESS
+  // Copy global valueRange option over to the first axis.
+  // NOTE(konigsberg): Are these two statements necessary?
+  // I tried removing it. The automated tests pass, and manually
+  // messing with tests/zoom.html showed no trouble.
+  v = this.attr_('valueRange');
+  if (v) this.axes_[0].valueRange = v;
 
   if (valueWindows !== undefined) {
     // Restore valueWindow settings.