]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Stored pixel ratio in a variable with a fallback value for browsers that doesn't... 1690/head
authorCedric van Putten <cedric@peakfijn.nl>
Tue, 24 Nov 2015 10:26:24 +0000 (11:26 +0100)
committerCedric van Putten <cedric@peakfijn.nl>
Tue, 24 Nov 2015 10:26:24 +0000 (11:26 +0100)
src/core/core.helpers.js

index 50d5c51ecb02d93adcc7b1368724d3cfaf9bb4a6..d8c8ac4df0d2fe02f59b0de062a33ede4780de39 100644 (file)
                        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';
                                // 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