Chart.js responsive resize with maintainAspectRatio and container height constraint
0 reputation · 30 Jul 2024, 21:55 UTC
Goal is predictable canvas sizing for a responsive Chart.js chart with responsive true and maintainAspectRatio true in a fluid layout.
The relevant constraint is a parent container without an explicit height, such as height auto derived from content flow. Documentation describes responsive resizing, but the minimum container size requirement and the desired canvas sizing in this edge case are not clearly bounded.
Version assumptions are Chart.js 3.x and 4.x where responsive and maintainAspectRatio are standard options. Practical verification would involve a minimal page to observe sizing behavior under window resize.
What minimum height constraint is expected for the container when maintainAspectRatio is true? Does maintainAspectRatio require an explicit height on the container to compute dimensions? What desired behavior should be defined for height:auto containers to avoid undefined sizing?