chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.9k stars 11.88k forks source link

do not attempt to clear canvas if one does not exist #11764

Closed DAcodedBEAT closed 1 month ago

DAcodedBEAT commented 1 month ago

Expected behavior

clearCanvas() from helpers.canvas.ts should only call getContext() on valid truth-y ctx values.

Current behavior

helpers.canvas.js:119 Uncaught TypeError: Cannot read properties of null (reading 'getContext')
    at clearCanvas (helpers.canvas.js:119:23)
    at Chart.clear (core.controller.js:268:5)
    at Chart.draw (core.controller.js:718:10)
    at core.animator.js:89:15
    at Map.forEach (<anonymous>)
    at Animator._update (core.animator.js:60:18)
    at core.animator.js:45:12

Closes #11743

Reproducible sample

https://github.com/chartjs/Chart.js/issues/11743

Optional extra steps/info to reproduce

No response

Context

.

chart.js version

4.4.2

Browser name and version

experienced on multiple browsers

Link to your project

No response

DAcodedBEAT commented 1 month ago

Thanks @LeeLenaleee , do you have an approximation for 4.5.0 being released?

LeeLenaleee commented 1 month ago

I think we might be able to do a 4.4.3 release since there are only bug fixes soon