Skip to content

Animation doesn't work if I change the size of pie chart #12167

@MaximKorniyenko

Description

@MaximKorniyenko

Documentation Is:

  • Missing or needed?
  • Confusing
  • Not sure?

Please Explain in Detail...

When I change the size of my chart animation and reload the page, the animation sometimes doesn’t work. I tested different sizes and found that it only works reliably when the size is a multiple of 4. After hours of investigation, I realized this happens because my devicePixelRatio (DPR) is 1.25.

With a fractional DPR, Chart.js calculates the chart radius as a non-integer. When the canvas tries to draw the animation, the browser rounds the size, which triggers a resize internally. As a result, the animation does not play.

I think this behavior should be mentioned in the Chart.js documentation, as it can be confusing for developers.

Your Proposal for Changes

Write about this behaviour in documentation

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions