From ae51789c32cf380a153ea9f4d96f861898cc03fd Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Tue, 24 Nov 2015 11:26:24 +0100 Subject: [PATCH] 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) --- src/core/core.helpers.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 -- 2.47.2