X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fdygraph.js;h=878a747e69355d8c016e91d5ca482363536a7667;hb=refs%2Fheads%2F540-fixup;hp=fc13b33a0bef6f69239c52b512ad381fe2dae060;hpb=ba88073653a98c1ae9ac6233eeb057dd17536344;p=dygraphs.git diff --git a/src/dygraph.js b/src/dygraph.js index fc13b33..878a747 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -65,12 +65,6 @@ var Dygraph = (function() { * options, see http://dygraphs.com/options.html. */ var Dygraph = function(div, data, opts) { - // These have to go above the "Hack for IE" in __init__ since .ready() can be - // called as soon as the constructor returns. Once support for OldIE is - // dropped, this can go down with the rest of the initializers. - this.is_initial_draw_ = true; - this.readyFns_ = []; - this.__init__(div, data, opts); }; @@ -396,6 +390,9 @@ Dygraph.addedAnnotationCSS = false; * @private */ Dygraph.prototype.__init__ = function(div, file, attrs) { + this.is_initial_draw_ = true; + this.readyFns_ = []; + // Support two-argument constructor if (attrs === null || attrs === undefined) { attrs = {}; } @@ -406,7 +403,7 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { } if (!div) { - throw 'Constructing dygraph with a non-existent div!'; + throw new Error('Constructing dygraph with a non-existent div!'); } // Copy the important bits into the object @@ -3250,9 +3247,9 @@ Dygraph.prototype.parseDataTable_ = function(data) { this.attrs_.axes.x.ticker = Dygraph.numericTicks; this.attrs_.axes.x.axisLabelFormatter = this.attrs_.axes.x.valueFormatter; } else { - console.error("only 'date', 'datetime' and 'number' types are supported " + - "for column 1 of DataTable input (Got '" + indepType + "')"); - return null; + throw new Error( + "only 'date', 'datetime' and 'number' types are supported " + + "for column 1 of DataTable input (Got '" + indepType + "')"); } // Array of the column indices which contain data (and not annotations). @@ -3274,8 +3271,9 @@ Dygraph.prototype.parseDataTable_ = function(data) { } hasAnnotations = true; } else { - console.error("Only 'number' is supported as a dependent type with Gviz." + - " 'string' is only supported if displayAnnotations is true"); + throw new Error( + "Only 'number' is supported as a dependent type with Gviz." + + " 'string' is only supported if displayAnnotations is true"); } } @@ -3749,6 +3747,10 @@ Dygraph.addAnnotationRule = function() { console.warn("Unable to add default annotation CSS rule; display may be off."); }; +if (typeof exports === "object" && typeof module !== "undefined") { + module.exports = Dygraph; +} + return Dygraph; })();