Change defaults after render leads to: TypeError: Cannot read properties of undefined (reading 'height')
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
I would expect exception on changing defaults after render or correctly react on new values.
### Current behavior
It may be minor but I spent one day debugging it. When you set `Chart.defaults.font` after render with `responsive: true` you can get NPE and puzzle over the reasons. It may happen when you do in the React app in different places.
```
Uncaught TypeError: Cannot read properties of undefined (reading 'height')
at eval (chart.js:8605:1)
at Array.forEach ()
at Legend._draw (chart.js:8587:1)
at Legend.draw (chart.js:8498:1)
at Object.draw (chart.js:3130:1)
at Chart.draw (chart.js:6094:1)
at Chart.render (chart.js:6070:1)
at Chart._resize (chart.js:5777:1)
at Chart.resize (chart.js:5747:1)
at listener (chart.js:6304:1)
at eval (chart.js:3397:1)
at eval (helpers.dataset.js:588:1)
at r (helpers.js:97:17)
```
### Reproducible sample
https://codepen.io/dimka-747/pen/yyJdrYe
### Optional extra steps/info to reproduce
Just open devtools in the codepan and see the exception
### Possible solution
_No response_
### Context
_No response_
### chart.js version
v4.5.1
### Browser name and version
Version 144.0.7559.135 (Official Build) (arm64)
### Link to your project
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.