fix: Avoid the resize loop by fixing the rounding error in the retinaScale function.

This commit is contained in:
Guy Baron 2022-12-16 22:01:05 -05:00
parent f70d6afcc2
commit 23525abc6a
2 changed files with 2 additions and 5 deletions

View File

@ -295,8 +295,8 @@ class Chart {
const newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();
const mode = this.width ? 'resize' : 'attach';
this.width = newSize.width;
this.height = newSize.height;
this.width = Math.floor(newSize.width);
this.height = Math.floor(newSize.height);
this._aspectRatio = this.aspectRatio;
if (!retinaScale(this, newRatio, true)) {
return;

View File

@ -222,9 +222,6 @@ export function retinaScale(
const deviceHeight = Math.floor(chart.height * pixelRatio);
const deviceWidth = Math.floor(chart.width * pixelRatio);
chart.height = deviceHeight / pixelRatio;
chart.width = deviceWidth / pixelRatio;
const canvas = chart.canvas;
// If no style has been set on the canvas, the render size is used as display size,