Skip to content

[BUG] Responsive canvas grows indefinitely in a container sized in % #5805

@developMediaSoft

Description

@developMediaSoft

When JavaScript resizes the canvas of a responsive chart to the canvas's relatively sized container, this will cause the container to be resized as well which will, in turn, trigger another canvas resizing and create an infinite loop where the chart will grow indefinitely (at least vertically).

Expected Behavior

The canvas fits the container without expanding it

Current Behavior

Canvas and its container grow indefinitely: https://codepen.io/bugmenot/pen/EdBogW

Possible Solution

Set the canvas's box-sizing to border-boxl. This will include borders/padding in the new canvas size and prevent the canvas from resizing the container: https://codepen.io/bugmenot/pen/oarqGz

Steps to Reproduce

Adopt the example from http://www.chartjs.org/docs/latest/general/responsive.html#important-note simply changing viewport units to percentages

Context

I'm actually trying to isolate another problem. This one I've just encountered trying to create a test case forking the example mentioned above.

Environment

  • Chart.js version: 2.5.0, reproducible in 2.7.3
  • Browser name and version: Firefox Quantum 62.0.3 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions