From fc80a39612bb80a3f0ec537622bb104b5737a6ea Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 1 Dec 2009 09:07:11 -0800 Subject: [PATCH] remove MochiKit.Base.update --- dygraph-canvas.js | 6 +++--- dygraph.js | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 45d27af..d1594f3 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -17,7 +17,7 @@ DygraphLayout = function(dygraph, options) { this.dygraph_ = dygraph; this.options = {}; // TODO(danvk): remove, use attr_ instead. - MochiKit.Base.update(this.options, options ? options : {}); + Dygraph.update(this.options, options ? options : {}); this.datasets = new Array(); }; @@ -146,7 +146,7 @@ DygraphLayout.prototype.removeAllDatasets = function() { * @param {Object} new_options an associative array of new properties */ DygraphLayout.prototype.updateOptions = function(new_options) { - MochiKit.Base.update(this.options, new_options ? new_options : {}); + Dygraph.update(this.options, new_options ? new_options : {}); }; // Subclass PlotKit.CanvasRenderer to add: @@ -179,7 +179,7 @@ DygraphCanvasRenderer = function(dygraph, element, layout, options) { "drawXGrid": true, "gridLineColor": "rgb(128,128,128)" }; - MochiKit.Base.update(this.options, options); + Dygraph.update(this.options, options); this.layout = layout; this.element = element; diff --git a/dygraph.js b/dygraph.js index 8b5124d..1cb4b62 100644 --- a/dygraph.js +++ b/dygraph.js @@ -125,7 +125,7 @@ Dygraph.prototype.__old_init__ = function(div, file, labels, attrs) { if (labels != null) { var new_labels = ["Date"]; for (var i = 0; i < labels.length; i++) new_labels.push(labels[i]); - MochiKit.Base.update(attrs, { 'labels': new_labels }); + Dygraph.update(attrs, { 'labels': new_labels }); } this.__init__(div, file, attrs); }; @@ -178,10 +178,10 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { // user_attrs_ and then computed attrs_. This way Dygraphs can set intelligent // defaults without overriding behavior that the user specifically asks for. this.user_attrs_ = {}; - MochiKit.Base.update(this.user_attrs_, attrs); + Dygraph.update(this.user_attrs_, attrs); this.attrs_ = {}; - MochiKit.Base.update(this.attrs_, Dygraph.DEFAULT_ATTRS); + Dygraph.update(this.attrs_, Dygraph.DEFAULT_ATTRS); // Make a note of whether labels will be pulled from the CSV file. this.labelsFromCSV_ = (this.attr_("labels") == null); @@ -194,8 +194,8 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { this.layoutOptions_ = { 'errorBars': (this.attr_("errorBars") || this.attr_("customBars")), 'xOriginIsZero': false }; - MochiKit.Base.update(this.layoutOptions_, this.attrs_); - MochiKit.Base.update(this.layoutOptions_, this.user_attrs_); + Dygraph.update(this.layoutOptions_, this.attrs_); + Dygraph.update(this.layoutOptions_, this.user_attrs_); this.layout_ = new DygraphLayout(this, this.layoutOptions_); @@ -203,8 +203,8 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { this.renderOptions_ = { colorScheme: this.colors_, strokeColor: null, axisLineWidth: Dygraph.AXIS_LINE_WIDTH }; - MochiKit.Base.update(this.renderOptions_, this.attrs_); - MochiKit.Base.update(this.renderOptions_, this.user_attrs_); + Dygraph.update(this.renderOptions_, this.attrs_); + Dygraph.update(this.renderOptions_, this.user_attrs_); this.plotter_ = new DygraphCanvasRenderer(this, this.hidden_, this.layout_, this.renderOptions_); @@ -388,9 +388,9 @@ Dygraph.prototype.setColors_ = function() { // TODO(danvk): update this w/r/t/ the new options system. this.renderOptions_.colorScheme = this.colors_; - MochiKit.Base.update(this.plotter_.options, this.renderOptions_); - MochiKit.Base.update(this.layoutOptions_, this.user_attrs_); - MochiKit.Base.update(this.layoutOptions_, this.attrs_); + Dygraph.update(this.plotter_.options, this.renderOptions_); + Dygraph.update(this.layoutOptions_, this.user_attrs_); + Dygraph.update(this.layoutOptions_, this.attrs_); } // The following functions are from quirksmode.org @@ -440,7 +440,7 @@ Dygraph.prototype.createStatusMessage_ = function(){ "background": "white", "textAlign": "left", "overflow": "hidden"}; - MochiKit.Base.update(messagestyle, this.attr_('labelsDivStyles')); + Dygraph.update(messagestyle, this.attr_('labelsDivStyles')); var div = document.createElement("div"); for (var name in messagestyle) { div.style[name] = messagestyle[name]; @@ -1570,6 +1570,15 @@ Dygraph.prototype.parseDataTable_ = function(data) { } // These functions are all based on MochiKit. +Dygraph.update = function (self, o) { + if (typeof(o) != 'undefined' && o !== null) { + for (var k in o) { + self[k] = o[k]; + } + } + return self; +}; + Dygraph.isArrayLike = function (o) { var typ = typeof(o); if ( @@ -1665,7 +1674,7 @@ Dygraph.prototype.updateOptions = function(attrs) { if (attrs.valueRange) { this.valueRange_ = attrs.valueRange; } - MochiKit.Base.update(this.user_attrs_, attrs); + Dygraph.update(this.user_attrs_, attrs); this.labelsFromCSV_ = (this.attr_("labels") == null); -- 2.7.4