Closure fix type Dyraph->Dygraph.
[dygraphs.git] / dygraph-canvas.js
index 7b0cebf..2824003 100644 (file)
@@ -39,7 +39,7 @@
  * 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 {Dygraph} 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.
@@ -57,8 +57,6 @@ var DygraphCanvasRenderer = function(dygraph, element, elementContext, layout) {
   this.height = this.element.height;
   this.width = this.element.width;
 
-  this.elementContext.save();
-
   // --- check whether everything is ok before we return
   if (!this.isIE && !(DygraphCanvasRenderer.isSupported(this.element)))
       throw "Canvas is not supported.";
@@ -127,11 +125,6 @@ DygraphCanvasRenderer.prototype.clear = function() {
   context.clearRect(0, 0, this.width, this.height);
 };
 
-DygraphCanvasRenderer.prototype.onDoneDrawing = function() {
-  // balances the save called in the constructor.
-  this.elementContext.restore();
-}
-
 /**
  * Checks whether the browser supports the <canvas> tag.
  * @private
@@ -738,13 +731,21 @@ DygraphCanvasRenderer._fillPlotter = function(e) {
         'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + fillAlpha + ')';
     ctx.fillStyle = err_color;
     ctx.beginPath();
-    while(iter.hasNext) {
+    var last_x, is_first = true;
+    while (iter.hasNext) {
       var point = iter.next();
       if (!Dygraph.isOK(point.y)) {
         prevX = NaN;
         continue;
       }
       if (stackedGraph) {
+        if (!is_first && last_x == point.xval) {
+          continue;
+        } else {
+          is_first = false;
+          last_x = point.xval;
+        }
+
         currBaseline = baseline[point.canvasx];
         var lastY;
         if (currBaseline === undefined) {