Skip to content

Commit

Permalink
fix: Avoid the resize loop by fixing the rounding error in the retina…
Browse files Browse the repository at this point in the history
…Scale function.
  • Loading branch information
gbaron committed Dec 17, 2022
1 parent f70d6af commit 23525ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/core.controller.js
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/helpers/helpers.dom.ts
Expand Up @@ -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,
Expand Down

0 comments on commit 23525ab

Please sign in to comment.