"use strict";
+/**
+ * @constructor
+ *
+ * This gets called when there are "new points" to chart. This is generally the
+ * case when the underlying data being charted has changed. It is _not_ called
+ * in the common case that the user has zoomed or is panning the view.
+ *
+ * The chart canvas has already been created by the Dygraph object. The
+ * renderer simply gets a drawing context.
+ *
+ * @param {Dyraph} dygraph The chart to which this renderer belongs.
+ * @param {Canvas} element The <canvas> DOM element on which to draw.
+ * @param {CanvasRenderingContext2D} elementContext The drawing context.
+ * @param {DygraphLayout} layout The chart's DygraphLayout object.
+ *
+ * TODO(danvk): remove the elementContext property.
+ */
var DygraphCanvasRenderer = function(dygraph, element, elementContext, layout) {
this.dygraph_ = dygraph;
return this.dygraph_.attr_(x);
};
+/**
+ * Clears out all chart content and DOM elements.
+ * This is called immediately before render() on every frame, including
+ * during zooms and pans.
+ * @private
+ */
DygraphCanvasRenderer.prototype.clear = function() {
var context;
if (this.isIE) {
this.chartLabels = {};
};
-
+/**
+ * Checks whether the browser supports the <canvas> tag.
+ * @private
+ */
DygraphCanvasRenderer.isSupported = function(canvasName) {
var canvas = null;
try {
};
/**
- * Draw an X/Y grid on top of the existing plot
+ * 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
+ * and zooms.
+ * @private
*/
DygraphCanvasRenderer.prototype.render = function() {
// Draw the new X/Y grid. Lines appear crisper when pixels are rounded to
Dygraph.prototype.renderGraph_ = function(is_initial_draw) {
this.plotter_.clear();
this.plotter_.render();
+
+ // TODO(danvk): is this a performance bottleneck when panning?
+ // The interaction canvas should already be empty in that situation.
this.canvas_.getContext('2d').clearRect(0, 0, this.canvas_.width,
this.canvas_.height);