Skip to content

Commit 5feebdf

Browse files
authored
Fix charts shinking in size on certain Zoom values in Chrome (#12097)
1 parent b5ee134 commit 5feebdf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/helpers/helpers.dom.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ export function retinaScale(
211211
forceStyle?: boolean
212212
): boolean | void {
213213
const pixelRatio = forceRatio || 1;
214-
const deviceHeight = Math.floor(chart.height * pixelRatio);
215-
const deviceWidth = Math.floor(chart.width * pixelRatio);
214+
const deviceHeight = round1(chart.height * pixelRatio);
215+
const deviceWidth = round1(chart.width * pixelRatio);
216216

217-
(chart as PrivateChart).height = Math.floor(chart.height);
218-
(chart as PrivateChart).width = Math.floor(chart.width);
217+
(chart as PrivateChart).height = round1(chart.height);
218+
(chart as PrivateChart).width = round1(chart.width);
219219

220220
const canvas = chart.canvas;
221221

test/specs/helpers.dom.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ describe('DOM helpers tests', function() {
268268
helpers.retinaScale(chart, devicePixelRatio, true);
269269

270270
var canvas = chart.canvas;
271-
expect(canvas.width).toBe(Math.floor(chartWidth * devicePixelRatio));
272-
expect(canvas.height).toBe(Math.floor(chartHeight * devicePixelRatio));
271+
expect(canvas.width).toBe(Math.round(chartWidth * devicePixelRatio));
272+
expect(canvas.height).toBe(Math.round(chartHeight * devicePixelRatio));
273273

274274
expect(chart.width).toBe(chartWidth);
275275
expect(chart.height).toBe(chartHeight);

0 commit comments

Comments
 (0)