Chartjs-How to dynamically render new list of charts based on a dropdown filter?

0👍

You can use events to re-call the script. For example, you could catch which field has been updated, using the updated method:

public function updated($field, $value) 
{
    // Validate which field should trigger a chart update. If all updates should, no if statement is needed.
    if ($field === 'questions') {
        $this->dispatchBrowserEvent('update-chart');
    }
}

Then in the frontend, you can catch it:

window.addEventListener('update-chart', () => {
    // Tear down current chart and initialize new chart
});

Leave a comment