From: Cedric van Putten Date: Tue, 24 Nov 2015 10:26:24 +0000 (+0100) Subject: Stored pixel ratio in a variable with a fallback value for browsers that doesn't... X-Git-Tag: 2.0.0-beta1~11^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F1690%2Fhead;p=thirdparty%2FChart.js.git Stored pixel ratio in a variable with a fallback value for browsers that doesn't support `window.devicePixelRatio` fixing rendering issues for IE10 and IE9. (issue #1622) --- diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 50d5c51ec..d8c8ac4df 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -741,12 +741,12 @@ var ctx = chart.ctx; var width = chart.canvas.width; var height = chart.canvas.height; - chart.currentDevicePixelRatio = window.devicePixelRatio || 1; + var pixelRatio = chart.currentDevicePixelRatio = window.devicePixelRatio || 1; - if (window.devicePixelRatio !== 1) { - ctx.canvas.height = height * window.devicePixelRatio; - ctx.canvas.width = width * window.devicePixelRatio; - ctx.scale(window.devicePixelRatio, window.devicePixelRatio); + if (pixelRatio !== 1) { + ctx.canvas.height = height * pixelRatio; + ctx.canvas.width = width * pixelRatio; + ctx.scale(pixelRatio, pixelRatio); ctx.canvas.style.width = width + 'px'; ctx.canvas.style.height = height + 'px'; @@ -754,7 +754,7 @@ // Store the device pixel ratio so that we can go backwards in `destroy`. // The devicePixelRatio changes with zoom, so there are no guarantees that it is the same // when destroy is called - chart.originalDevicePixelRatio = chart.originalDevicePixelRatio || window.devicePixelRatio; + chart.originalDevicePixelRatio = chart.originalDevicePixelRatio || pixelRatio; } }, //-- Canvas methods