X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=27b1b3663b78a5c1962b9b3eb32351a31d575b15;hb=33b5c4b245bf29f3e908931bf70dde00b5fc8a51;hp=7b80e327aba4971883191567c8077fa9de0ee51c;hpb=3e644ed896f7184c93bc7d16f285a33a4c2e39f2;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 7b80e32..27b1b36 100644 --- a/dygraph.js +++ b/dygraph.js @@ -43,6 +43,9 @@ */ +// For "production" code, this gets set to false by uglifyjs. +if (typeof(DEBUG) === 'undefined') DEBUG=true; + /*jshint globalstrict: true */ /*global DygraphLayout:false, DygraphCanvasRenderer:false, DygraphOptions:false, G_vmlCanvasManager:false,ActiveXObject:false */ "use strict"; @@ -665,16 +668,16 @@ Dygraph.prototype.toString = function() { * @return { ... } The value of the option. */ Dygraph.prototype.attr_ = function(name, seriesName) { -// - if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { - console.error('Must include options reference JS for testing'); - } else if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(name)) { - console.error('Dygraphs is using property ' + name + ', which has no ' + - 'entry in the Dygraphs.OPTIONS_REFERENCE listing.'); - // Only log this error once. - Dygraph.OPTIONS_REFERENCE[name] = true; - } -// + if (DEBUG) { + if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { + console.error('Must include options reference JS for testing'); + } else if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(name)) { + console.error('Dygraphs is using property ' + name + ', which has no ' + + 'entry in the Dygraphs.OPTIONS_REFERENCE listing.'); + // Only log this error once. + Dygraph.OPTIONS_REFERENCE[name] = true; + } + } return seriesName ? this.attributes_.getForSeries(name, seriesName) : this.attributes_.get(name); }; @@ -1621,7 +1624,7 @@ Dygraph.prototype.doZoomXDates_ = function(minDate, maxDate) { var that = this; this.doAnimatedZoom(old_window, new_window, null, null, function() { if (that.getFunctionOption("zoomCallback")) { - that.getFunctionOption("zoomCallback")( + that.getFunctionOption("zoomCallback").call(that, minDate, maxDate, that.yAxisRanges()); } }); @@ -1654,7 +1657,7 @@ Dygraph.prototype.doZoomY_ = function(lowY, highY) { this.doAnimatedZoom(null, null, oldValueRanges, newValueRanges, function() { if (that.getFunctionOption("zoomCallback")) { var xRange = that.xAxisRange(); - that.getFunctionOption("zoomCallback")( + that.getFunctionOption("zoomCallback").call(that, xRange[0], xRange[1], that.yAxisRanges()); } }); @@ -1709,7 +1712,7 @@ Dygraph.prototype.resetZoom = function() { } this.drawGraph_(); if (this.getFunctionOption("zoomCallback")) { - this.getFunctionOption("zoomCallback")( + this.getFunctionOption("zoomCallback").call(this, minDate, maxDate, this.yAxisRanges()); } return; @@ -1752,7 +1755,7 @@ Dygraph.prototype.resetZoom = function() { } } if (that.getFunctionOption("zoomCallback")) { - that.getFunctionOption("zoomCallback")( + that.getFunctionOption("zoomCallback").call(that, minDate, maxDate, that.yAxisRanges()); } }); @@ -1989,7 +1992,7 @@ Dygraph.prototype.mouseMove_ = function(event) { var callback = this.getFunctionOption("highlightCallback"); if (callback && selectionChanged) { - callback(event, + callback.call(this, event, this.lastx_, this.selPoints_, this.lastRow_, @@ -2119,7 +2122,7 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) { ctx.lineWidth = this.getNumericOption('strokeWidth', pt.name); ctx.strokeStyle = color; ctx.fillStyle = color; - callback(this, pt.name, ctx, canvasx, pt.canvasy, + callback.call(this, this, pt.name, ctx, canvasx, pt.canvasy, color, circleSize, pt.idx); } ctx.restore(); @@ -2202,10 +2205,10 @@ Dygraph.prototype.setSelection = function(row, opt_seriesName, opt_locked) { */ Dygraph.prototype.mouseOut_ = function(event) { if (this.getFunctionOption("unhighlightCallback")) { - this.getFunctionOption("unhighlightCallback")(event); + this.getFunctionOption("unhighlightCallback").call(this, event); } - if (this.getFunctionOption("hideOverlayOnMouseOut") && !this.lockedSet_) { + if (this.getBooleanOption("hideOverlayOnMouseOut") && !this.lockedSet_) { this.clearSelection(); } }; @@ -2691,7 +2694,7 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { if (this.getFunctionOption('underlayCallback')) { // NOTE: we pass the dygraph object to this callback twice to avoid breaking // users who expect a deprecated form of this callback. - this.getFunctionOption('underlayCallback')( + this.getFunctionOption('underlayCallback').call(this, this.hidden_ctx_, this.layout_.getPlotArea(), this, this); } @@ -3719,7 +3722,7 @@ Dygraph.prototype.ready = function(callback) { if (this.is_initial_draw_) { this.readyFns_.push(callback); } else { - callback(this); + callback.call(this, this); } };