-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Update infinite loop or no chart update #611
Comments
Well, you have included the reactivePropMixin, which will create a variable named chartData and add a watcher to it. But then, you add your own watcher to chartData with |
If i remove the watcher, chart does't update. Chart.js:6719 Uncaught TypeError: Cannot read property 'skip' of undefined. So i have to remove the mixins, but I still have the infi loop error. My new code: <script>
import 'chartjs-adapter-moment';
import { Line } from 'vue-chartjs'
export default {
extends: Line,
props: ['options', 'chartData'],
mounted () {
this.renderChart(this.chartData, this.options);
},
watch: {
chartData: {
deep: true,
handler: function () {
this.renderChart(this.chartData, this.options);
//this.$data._chart.update();
}
}
}
}
</script> Thank for your help |
This could be because of the If you print out the object you will notice that it is quite big also. Oh I see that you are using the |
Alright ! Thank for you reply. I have tried to create a new properties "newData, but I have always the error :/ Could you explain to me how to settle it? Whitout "deep: true", that don't work. Thank. |
Bump. Getting the same error with the following:
|
Bump. is it possible to have a solution to this problem? In local dev mode activated, it does not affect the functioning of the site, but after build, the site makes a sort of Infinite loop and broken everything we are forced to reload the page. |
Like I said, it is very unlikeley that it will work with And it also depends on how you mutate your data.
If you own watcher does not trigger if you just watch the export default {
watch: {
'chartData.datasets': function(a, b) {}
}
} |
I just sucked, without the deep: true, nothing works. Maybe by calling a chartjs update just after pushing the data? But how to do it, the renderChart function is not accessible from my other Vue Component :/ |
Have you tried to add the watcher to |
I tried both. I also tried to update the chartjs from my VueComponent or is my chart but did not arrive Edit: In call this:
where is my chartjs is import, that work. But I don't know if it's the right method ! |
I had the same problem but kinda fixed it with with a custom watcher (without mixins) using a support boolean to execute the update only once per watch trigger. NB: the nextTick is the reason it works, and that's also a better solution than a setTimeout.
I still need to test if better, but the infinite loop seems to be gone. PS: I've also tried using lodash to compare newVal with oldVal without success, and was also time consuming |
@Hextar Thanks for your solution, it kinda works for me. Though, I'm still having a slow infinite loop (each ±100ms, my watcher is triggered). |
Removing mixins.reactiveProp and setting a deep watch to chartData for renderChart() worked for me. My infinite loop came from setting values for chartjs-annotation-plugin to the chart's options. As @ph1823 mentioned, using the reactiveProp worked fine in local environment but browser became unresponsive in dev environment. I didn't find the inifinite loop warning until I removed the plugin code because this was a base component shared with other chart components. I'm on vue 2.6.14 and vue-chartjs 3.5.1 and chartjs-plugin-annotation 0.5.7. |
to enforce the update of the chart w/o adding a watcher you could try adding a |
Expected Behavior
No error, and update chart.
Actual Behavior
Update chart, but an error:
I have read #487 and #518 and #416 for try fix this, and #44 but without success.
If i juste use reactiveProps without update metohd, my chart dont update ;c
My actually chart code:
And method to push data:
I have tried without oldStats variable, but no work.
Environment
For 2 days I have been looking for all possible solutions, but can't find any that work.
Thank you for making this vuejs "plugin" it is a very good plugins, and thank you for the help you would bring me! Sorry for my bad english ;c
The text was updated successfully, but these errors were encountered: