From: Gregory Jordan Date: Tue, 21 Oct 2014 17:24:41 +0000 (-0400) Subject: Fix ghosting issues when viewing graphs with browser zoomed out. Closes #440. X-Git-Tag: v1.1.0~31^2~5 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=fa8ac513bcce9f01c99e436a7cc791c4f93b0e34;p=dygraphs.git Fix ghosting issues when viewing graphs with browser zoomed out. Closes #440. --- diff --git a/dygraph-utils.js b/dygraph-utils.js index 9e74c7d..68a3148 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -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; }