Fix ghosting issues when viewing graphs with browser zoomed out. Closes #440.
authorGregory Jordan <gjordan@google.com>
Tue, 21 Oct 2014 17:24:41 +0000 (13:24 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Tue, 4 Nov 2014 22:20:16 +0000 (17:20 -0500)
dygraph-utils.js

index 9e74c7d..68a3148 100644 (file)
@@ -831,13 +831,20 @@ Dygraph.createCanvas = function() {
  */
 Dygraph.getContextPixelRatio = function(context) {
   try {
-    var devicePixelRatio = window.devicePixelRatio || 1,
-        backingStoreRatio = context.webkitBackingStorePixelRatio ||
+    var devicePixelRatio = window.devicePixelRatio;
+    var backingStoreRatio = context.webkitBackingStorePixelRatio ||
                             context.mozBackingStorePixelRatio ||
                             context.msBackingStorePixelRatio ||
                             context.oBackingStorePixelRatio ||
-                            context.backingStorePixelRatio || 1;
-    return devicePixelRatio / backingStoreRatio;
+                            context.backingStorePixelRatio;
+    if (devicePixelRatio !== undefined &&
+        backingStorePixelRatio !== undefined) {
+      return devicePixelRatio / backingStoreRatio;
+    } else {
+      // If either value is undefined, the ratio is meaningless so we want to
+      // return 1.
+      return 1;
+    }
   } catch (e) {
     return 1;
   }