};
/**
- * @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
* @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();
};
this.colorsMap_[labels[1 + i]] = colorStr;
}
}
-
- this.plotter_.setColors(this.colors_);
};
/**
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.
annotations.prototype.activate = function(g) {
return {
clearChart: this.clearChart,
- drawChart: this.drawChart
+ didDrawChart: this.didDrawChart
};
};
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.
return {
layout: this.layout,
clearChart: this.clearChart,
- drawChart: this.drawChart
+ willDrawChart: this.willDrawChart
};
};
this.detachLabels();
}
-axes.prototype.drawChart = function(e) {
+axes.prototype.willDrawChart = function(e) {
var g = e.dygraph;
if (!g.getOption('drawXAxis') && !g.getOption('drawYAxis')) return;
return {
layout: this.layout,
// clearChart: this.clearChart,
- drawChart: this.drawChart
+ didDrawChart: this.didDrawChart
};
};
}
};
-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');
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;
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
};
};
this.legend_div_.innerHTML = html;
};
-legend.prototype.drawChart = function(e) {
+legend.prototype.didDrawChart = function(e) {
this.deselect(e);
}