Remove isAndroid checks (#784)
[dygraphs.git] / src / dygraph-canvas.js
index 256edc1..7377239 100644 (file)
@@ -28,6 +28,7 @@
 "use strict";
 
 import * as utils from './dygraph-utils';
+import Dygraph from './dygraph';
 
 
 /**
@@ -67,19 +68,15 @@ var DygraphCanvasRenderer = function(dygraph, element, elementContext, layout) {
 
   // Set up a clipping area for the canvas (and the interaction canvas).
   // This ensures that we don't overdraw.
-  // on Android 3 and 4, setting a clipping area on a canvas prevents it from
-  // displaying anything.
-  if (!utils.isAndroid()) {
-    var ctx = this.dygraph_.canvas_ctx_;
-    ctx.beginPath();
-    ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);
-    ctx.clip();
+  var ctx = this.dygraph_.canvas_ctx_;
+  ctx.beginPath();
+  ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);
+  ctx.clip();
 
-    ctx = this.dygraph_.hidden_ctx_;
-    ctx.beginPath();
-    ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);
-    ctx.clip();
-  }
+  ctx = this.dygraph_.hidden_ctx_;
+  ctx.beginPath();
+  ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);
+  ctx.clip();
 };
 
 /**
@@ -153,7 +150,7 @@ DygraphCanvasRenderer._drawStyledLine = function(e,
   var ctx = e.drawingContext;
   ctx.save();
   if (stroking) {
-    ctx.installPattern(strokePattern);
+    if (ctx.setLineDash) ctx.setLineDash(strokePattern);
   }
 
   var pointsOnLine = DygraphCanvasRenderer._drawSeries(
@@ -162,7 +159,7 @@ DygraphCanvasRenderer._drawStyledLine = function(e,
       e, pointsOnLine, drawPointCallback, color, pointSize);
 
   if (stroking) {
-    ctx.uninstallPattern();
+    if (ctx.setLineDash) ctx.setLineDash([]);
   }
 
   ctx.restore();
@@ -219,18 +216,18 @@ DygraphCanvasRenderer._drawSeries = function(e,
       prevCanvasX = prevCanvasY = null;
     } else {
       isIsolated = false;
-      if (drawGapPoints || !prevCanvasX) {
+      if (drawGapPoints || prevCanvasX === null) {
         iter.nextIdx_ = i;
         iter.next();
         nextCanvasY = iter.hasNext ? iter.peek.canvasy : null;
 
         var isNextCanvasYNullOrNaN = nextCanvasY === null ||
             nextCanvasY != nextCanvasY;
-        isIsolated = (!prevCanvasX && isNextCanvasYNullOrNaN);
+        isIsolated = (prevCanvasX === null && isNextCanvasYNullOrNaN);
         if (drawGapPoints) {
           // Also consider a point to be "isolated" if it's adjacent to a
           // null point, excluding the graph edges.
-          if ((!first && !prevCanvasX) ||
+          if ((!first && prevCanvasX === null) ||
               (iter.hasNext && isNextCanvasYNullOrNaN)) {
             isIsolated = true;
           }
@@ -543,7 +540,7 @@ DygraphCanvasRenderer._errorPlotter = function(e) {
  * Proxy for CanvasRenderingContext2D which drops moveTo/lineTo calls which are
  * superfluous. It accumulates all movements which haven't changed the x-value
  * and only applies the two with the most extreme y-values.
- * 
+ *
  * Calls to lineTo/moveTo must have non-decreasing x-values.
  */
 DygraphCanvasRenderer._fastCanvasProxy = function(context) {