X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=720443a9354a7aced7ee804e3c4a4875c2e4a712;hb=ed8df44ec5bb0b1445474652d4de8f9cd52ca2cb;hp=c7f70873eda50f8a8df947bc90eb0e67e7f3d425;hpb=45df6dd0902ef39691f061a70f4702e606fb747e;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index c7f7087..720443a 100644 --- a/dygraph.js +++ b/dygraph.js @@ -355,6 +355,10 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { attrs = Dygraph.mapLegacyOptions_(attrs); + if (typeof(div) == 'string') { + div = document.getElementById(div); + } + if (!div) { Dygraph.error("Constructing dygraph with a non-existent div!"); return; @@ -570,45 +574,7 @@ Dygraph.prototype.attr_ = function(name, seriesName) { } // - // Building an array which we peruse in backwards order to find the correct value. - // Options are checked in this order: - // series, axis, user attrs, global attrs. - // TODO(konigsberg): Can this be made faster by starting with the series and working outward, - // rather than building an array? - - var sources = []; - sources.push(this.attrs_); - if (this.user_attrs_) { - sources.push(this.user_attrs_); - if (seriesName) { - if (this.user_attrs_.hasOwnProperty(seriesName)) { - sources.push(this.user_attrs_[seriesName]); - } - - // TODO(konigsberg): This special case ought to be documented. - if (seriesName === this.highlightSet_ && - this.user_attrs_.hasOwnProperty('highlightSeriesOpts')) { - sources.push(this.user_attrs_.highlightSeriesOpts); - } - } - } - - var ret = null; - for (var i = sources.length - 1; i >= 0; --i) { - var source = sources[i]; - if (source.hasOwnProperty(name)) { - ret = source[name]; - break; - } - } - - var computedValue = seriesName ? this.attributes_.findForSeries(name, seriesName) : this.attributes_.find(name); - if (ret !== computedValue) { - console.log("Mismatch", name, seriesName, ret, computedValue); - } - - var USE_NEW_VALUE = true; - return USE_NEW_VALUE ? computedValue : ret; + return seriesName ? this.attributes_.getForSeries(name, seriesName) : this.attributes_.get(name); }; /** @@ -3395,6 +3361,8 @@ Dygraph.prototype.updateOptions = function(input_attrs, block_redraw) { Dygraph.updateDeep(this.user_attrs_, attrs); + this.attributes_.reparseSeries(); + if (file) { this.file_ = file; if (!block_redraw) this.start_();