mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 04:09:08 +02:00
fix: Avoid the resize loop by fixing the rounding error in the retinaScale function.
This commit is contained in:
parent
f70d6afcc2
commit
23525abc6a
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user