I am trying to sync my chart' array data with my firebase value. Chart getting arrays for label and data. I would like to bind this Chart data value to my firebase object. Here is normal chart creation with hard coded static values:
data()
{
return {appChart: {data: {labels: ["A"], series: [[3]]}},}
},
Now, I would like to bind this value (3) with my firebase object.. Normally I can use firebase object like this with no problem:
new Vue({
data: () => ({ myObjA: null }),
firebase: {
myObjA: db.ref('myObjA'),
asObject:true
},
})
But I cant bind and dynamic update this myObjA with Chart array series ‘a’ like;
data()
{
return {appChart: {data: {labels: ["A"], series: [[myObjA]]}},}
},
How can I do that ?
You can change appChart
to be computed properties:
export default {
data: () => ({ myObjA: null }),
firebase: {
myObjA: db.ref('myObjA'),
asObject:true
},
computed: {
appChart() {
return {
data: {
labels: ["A"],
series: [[this.myObjA]]
}
}
}
}
}
</script>