Fix charts shinking in size on certain Zoom values in Chrome (#12097)

This commit is contained in:
Bojidar Marinov 2025-07-11 22:38:17 +03:00 committed by GitHub
parent b5ee134eff
commit 5feebdf7b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -211,11 +211,11 @@ export function retinaScale(
forceStyle?: boolean
): boolean | void {
const pixelRatio = forceRatio || 1;
const deviceHeight = Math.floor(chart.height * pixelRatio);
const deviceWidth = Math.floor(chart.width * pixelRatio);
const deviceHeight = round1(chart.height * pixelRatio);
const deviceWidth = round1(chart.width * pixelRatio);
(chart as PrivateChart).height = Math.floor(chart.height);
(chart as PrivateChart).width = Math.floor(chart.width);
(chart as PrivateChart).height = round1(chart.height);
(chart as PrivateChart).width = round1(chart.width);
const canvas = chart.canvas;

View File

@ -268,8 +268,8 @@ describe('DOM helpers tests', function() {
helpers.retinaScale(chart, devicePixelRatio, true);
var canvas = chart.canvas;
expect(canvas.width).toBe(Math.floor(chartWidth * devicePixelRatio));
expect(canvas.height).toBe(Math.floor(chartHeight * devicePixelRatio));
expect(canvas.width).toBe(Math.round(chartWidth * devicePixelRatio));
expect(canvas.height).toBe(Math.round(chartHeight * devicePixelRatio));
expect(chart.width).toBe(chartWidth);
expect(chart.height).toBe(chartHeight);