From: Dan Vanderkam Date: Fri, 6 Jul 2012 04:14:26 +0000 (-0700) Subject: Landing! X-Git-Tag: v1.0.0~239 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=98eb4713efecf58b904def42d9030e61bcbb4181;p=dygraphs.git Landing! --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 50ff486..3600b78 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -145,14 +145,6 @@ DygraphCanvasRenderer.isSupported = function(canvasName) { }; /** - * @param { [String] } colors Array of color strings. Should have one entry for - * each series to be rendered. - */ -DygraphCanvasRenderer.prototype.setColors = function(colors) { - this.colorScheme_ = colors; -}; - -/** * This method is responsible for drawing everything on the chart, including * lines, error bars, fills and axes. * It is called immediately after clear() on every frame, including during pans @@ -160,19 +152,6 @@ DygraphCanvasRenderer.prototype.setColors = function(colors) { * @private */ DygraphCanvasRenderer.prototype.render = function() { - // Draw the new X/Y grid. Lines appear crisper when pixels are rounded to - // half-integers. This prevents them from drawing in two rows/cols. - var ctx = this.elementContext; - function halfUp(x) { return Math.round(x) + 0.5; } - function halfDown(y){ return Math.round(y) - 0.5; } - - if (this.attr_('underlayCallback')) { - // NOTE: we pass the dygraph object to this callback twice to avoid breaking - // users who expect a deprecated form of this callback. - this.attr_('underlayCallback')(ctx, this.area, this.dygraph_, this.dygraph_); - } - - // Do the ordinary rendering, as before this._renderLineChart(); }; diff --git a/dygraph.js b/dygraph.js index 4f6b41b..bd3a4cc 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1090,8 +1090,6 @@ Dygraph.prototype.setColors_ = function() { this.colorsMap_[labels[1 + i]] = colorStr; } } - - this.plotter_.setColors(this.colors_); }; /** @@ -2341,11 +2339,20 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { this.cascadeEvents_('clearChart'); this.plotter_.clear(); - this.cascadeEvents_('drawChart', { + if (this.attr_('underlayCallback')) { + // NOTE: we pass the dygraph object to this callback twice to avoid breaking + // users who expect a deprecated form of this callback. + this.attr_('underlayCallback')( + this.hidden_ctx_, this.layout_.getPlotArea(), this, this); + } + + var e = { canvas: this.hidden_, drawingContext: this.hidden_ctx_, - }); + }; + this.cascadeEvents_('willDrawChart', e); this.plotter_.render(); + this.cascadeEvents_('didDrawChart', e); // TODO(danvk): is this a performance bottleneck when panning? // The interaction canvas should already be empty in that situation. diff --git a/plugins/annotations.js b/plugins/annotations.js index 7be7966..d47f8c7 100644 --- a/plugins/annotations.js +++ b/plugins/annotations.js @@ -30,7 +30,7 @@ annotations.prototype.toString = function() { annotations.prototype.activate = function(g) { return { clearChart: this.clearChart, - drawChart: this.drawChart + didDrawChart: this.didDrawChart }; }; @@ -47,7 +47,7 @@ annotations.prototype.clearChart = function(e) { this.detachLabels(); }; -annotations.prototype.drawChart = function(e) { +annotations.prototype.didDrawChart = function(e) { var g = e.dygraph; // Early out in the (common) case of zero annotations. diff --git a/plugins/axes.js b/plugins/axes.js index 940fcec..81068fe 100644 --- a/plugins/axes.js +++ b/plugins/axes.js @@ -33,7 +33,7 @@ axes.prototype.activate = function(g) { return { layout: this.layout, clearChart: this.clearChart, - drawChart: this.drawChart + willDrawChart: this.willDrawChart }; }; @@ -84,7 +84,7 @@ axes.prototype.clearChart = function(e) { this.detachLabels(); } -axes.prototype.drawChart = function(e) { +axes.prototype.willDrawChart = function(e) { var g = e.dygraph; if (!g.getOption('drawXAxis') && !g.getOption('drawYAxis')) return; diff --git a/plugins/chart-labels.js b/plugins/chart-labels.js index 5e544dc..af12bcb 100644 --- a/plugins/chart-labels.js +++ b/plugins/chart-labels.js @@ -23,7 +23,7 @@ chart_labels.prototype.activate = function(g) { return { layout: this.layout, // clearChart: this.clearChart, - drawChart: this.drawChart + didDrawChart: this.didDrawChart }; }; @@ -169,7 +169,7 @@ chart_labels.prototype.layout = function(e) { } }; -chart_labels.prototype.drawChart = function(e) { +chart_labels.prototype.didDrawChart = function(e) { var g = e.dygraph; if (this.title_div_) { this.title_div_.children[0].innerHTML = g.getOption('title'); diff --git a/plugins/grid.js b/plugins/grid.js index 3ccc2ae..6d59406 100644 --- a/plugins/grid.js +++ b/plugins/grid.js @@ -30,11 +30,11 @@ grid.prototype.toString = function() { grid.prototype.activate = function(g) { return { - drawChart: this.drawChart + willDrawChart: this.willDrawChart }; }; -grid.prototype.drawChart = function(e) { +grid.prototype.willDrawChart = function(e) { // Draw the new X/Y grid. Lines appear crisper when pixels are rounded to // half-integers. This prevents them from drawing in two rows/cols. var g = e.dygraph; diff --git a/plugins/legend.js b/plugins/legend.js index 5f7ac7e..721812c 100644 --- a/plugins/legend.js +++ b/plugins/legend.js @@ -100,7 +100,7 @@ legend.prototype.activate = function(g) { deselect: this.deselect, // TODO(danvk): rethink the name "predraw" before we commit to it in any API. predraw: this.predraw, - drawChart: this.drawChart + didDrawChart: this.didDrawChart }; }; @@ -132,7 +132,7 @@ legend.prototype.deselect = function(e) { this.legend_div_.innerHTML = html; }; -legend.prototype.drawChart = function(e) { +legend.prototype.didDrawChart = function(e) { this.deselect(e); }