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
});
- Chartjs-Chart.js BarChart not appearing
- Chartjs-How to show the chartjs bar chart data values labels as text?
Source:stackexchange.com