]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Use integer canvas dimensions (#12142) master
authorJosh Kelley <joshkel@gmail.com>
Sun, 16 Nov 2025 18:42:40 +0000 (13:42 -0500)
committerGitHub <noreply@github.com>
Sun, 16 Nov 2025 18:42:40 +0000 (19:42 +0100)
src/helpers/helpers.dom.ts

index 8224361c67190d4221068ff1e853dce44cd1c71c..b0c41eec0c027c017e0cf459899bac62b4b48ade 100644 (file)
@@ -227,12 +227,14 @@ export function retinaScale(
     canvas.style.width = `${chart.width}px`;
   }
 
+  const canvasHeight = Math.floor(deviceHeight);
+  const canvasWidth = Math.floor(deviceWidth);
   if (chart.currentDevicePixelRatio !== pixelRatio
-      || canvas.height !== deviceHeight
-      || canvas.width !== deviceWidth) {
+      || canvas.height !== canvasHeight
+      || canvas.width !== canvasWidth) {
     (chart as PrivateChart).currentDevicePixelRatio = pixelRatio;
-    canvas.height = deviceHeight;
-    canvas.width = deviceWidth;
+    canvas.height = canvasHeight;
+    canvas.width = canvasWidth;
     chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
     return true;
   }