0👍
There are two issues with your chartData
in the child component:
- it is not updated when data changes
- chart-js requires you to rebuild both the
chartData
object and thechartData.datasets
array to detect changes and redraw the chart
You can fix both by turning your chartData
into a computed property:
computed: {
chartData(){
return {
labels: this.labels,
datasets: [
{
borderColor: "#f6b09e",
backgroundColor: "rgb(246, 176, 157)",
label: "crimes",
data: this.dataset,
},
],
}
}
}
Here is a simplified playground
Source:stackexchange.com