2👍
found the fix.
had to fire an emit event when the button is pressed along with it’s values contained under $data.
Then added this in my blade file
window.onload = function() {
Livewire.on('refreshCharts', ($data) => {
var ctx = document.getElementById('pieChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
datasets: [{
data: $data,
backgroundColor: ['#7e22ce', '#fecaca'],
label: 'Post',
}, ],
labels: ['Published', 'Reviewing'],
},
options: {
responsive: true,
cutoutPercentage: 50,
legend: {
display: false,
},
},
});
})
}
- Chartjs-Customise size of data points , height and width in Chart.js?
- Chartjs-Rendering a chart.js component twice in a page
Source:stackexchange.com