0👍
✅
Since, you are initializing a new instance of chart each time the user selects an option, hence you need to destroy the previous instance of chart before initializing a new one.
To accomplish so, add the following before initializing your chart …
// destroy previous instance of chart
barGraph1 && barGraph1.chart && barGraph1.chart.destroy();
// initialize chart
barGraph1 = new Chart(frame, {
type: 'line',
data: chartdata1,
...
note: make sure barGraph1
variable is globally accessible
Source:stackexchange.com