0👍
your const myChart
declaration is inside generateGraph
function, only the code inside generateGraph
has access to const myChart
what you could do is to use window.myChart
instead of const myChart
so that the variable is globally available and you clearCanvas()
function can access it also using window.myChart.destroy()
- Chartjs-(MVC) Is this an efficient way of displaying chart data by date?
- Chartjs-Chartjs show seconds on the x axis and volume on the y
Source:stackexchange.com