How can I ensure that my charts diagram load every time I choose it from my dropdown?

๐Ÿ‘:0

HTML Code :

<div id="chartContainer">
  <canvas id="jobChart"></canvas>
</div>

JS CODE :

document.getElementById('job-role').addEventListener('change', function() {
   $('#jobChart').remove();
   $('#chartContainer').append('<canvas id="jobChart"><canvas>');
   
   //Here you need to call generate the graph again then add the values to dataset.   

   chart.data.datasets = jobDatasets[this.value]
   chart.update()
});

Leave a comment