Skip to content

Conversation

@joshkel
Copy link
Contributor

@joshkel joshkel commented Oct 28, 2025

As a result of #12097, the HTMLCanvasElement's width and height (which are always integers - see MDN) may be compared to fractional deviceWidth and deviceHeight, resulting in extra resize and update events being fired.

This PR rounds the dimensions for purposes of comparing to the canvas element's, which should put the behavior closer to Chart.js 4.5.0 and earlier.

I've tested this against #11224, my own code (which was generating errors due to an interaction between these extra events and some internal plugins), and https://codepen.io/joshkel/pen/azdjLGZ, and it seems to work.

Fixes #12143

As a result of chartjs#12097, the HTMLCanvasElement's `width` and `height` (which are always integers - see [MDN][1]) may be compared to fractional `deviceWidth` and `deviceHeight`, resulting in extra resize and update events being fired.

This PR rounds the dimensions for purposes of comparing to the canvas element's, which should put the behavior closer to Chart.js 4.5.0 and earlier.

I've tested this against chartjs#11224, my own code (which was generating errors due to an interaction between these extra events and some internal plugins), and https://codepen.io/joshkel/pen/azdjLGZ, and it seems to work.

[1]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#instance_properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes to resize events and animation in 4.5.1

2 participants