-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactivity of Options #106
Comments
I feel the same thing as you. Now I implement with the following way. export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
watch: {
'options': {
handler(newOption, oldOption) {
this.renderChart(this.chartData, this.options)
},
deep: true
}
}
}); |
Euledge, thank you very much for helping. Unfortunately, when I change my chart code to include the watch and subsequent renderChart(), it is affecting the size of the chart (it appears to be doubling the size of the chart on each subsequent re-render). My chart js now looks like this:
Did I misinterpret your changes? Thanks! |
Hi @crholliday You could try to call If this is not working, calling import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
watch: {
'options': {
handler (newOption, oldOption) {
this._chart.destroy()
this.renderChart(this.chartData, this.options)
},
deep: true
}
},
mounted () {
this.renderChart(this.chartData, this.options)
}
}) I will see if I can implement it as a feature ✌️ so it will work out of the box |
Hi @crholliday @apertureless |
Thanks Euledge and Apertureless... it is working now. |
I can confirm, calling again renderChart was too buggy.
|
Yeah due to the changes in v3
|
When I update data in Vue form which Chart get the data nothing happens. Console logs nothing...
This is how
For now it only works if I update whole |
Well, but you are talking now about your data, right? Not about your options. There are a ton of other issues, regarding the reactivity of data. First of all, you are importing the reactivity mixin but overwriting it in your local component. The mixin, will check of changes, and depending on the changes it will either It depends on how you are updating your data. http://vue-chartjs.org/#/home?id=limitations There are some limitations in javascript and vue, how to detect changes and what the watcher can detect. |
I think destroying the chart then render again is not a good behavior. export default {
extends: Line,
props: ['chartData', 'options'],
watch: {
options: {
handler() {
this.$data._chart.options = this.options
this.$data._chart.update()
},
deep: true
}
},
mounted() {
this.renderChart(this.chartData, this.options)
}
} |
I need to have Options be reactive so that it will update the title property. It does not appear to be watched in the mixin? No matter what I do below, the title will not re-render on the chart.
Environment
The text was updated successfully, but these errors were encountered: