-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
hello a q about reactivity #28
Comments
Hey, here is an example: https://github.com/apertureless/vue-chartjs/blob/master/src/examples/ReactiveExample.js which is also used on the demo page. If you have issues, please provide a jsfiddle or a minimal repo for reproduction. However the mixins are very generic. It may be better if you implement an update cyrcle yourself. Heres the source of the mixin: https://github.com/apertureless/vue-chartjs/blob/master/src/mixins/reactiveProp.js You can copy paste it as a local mixin and try to add debug output. See if the watcher triggers and if if (JSON.stringify(newDataLabels) === JSON.stringify(oldDataLabels)) works. |
checked examples but still wont work, heres a jsfiddle |
i solved it with emitting events and updating chart manually |
now i have another problem when moving through routes, without keep-alive Uncaught (in promise) TypeError: Cannot read property 'getContext' of undefined |
Hey @SerjoA Reactivitywell events are one way to go. Chartjs has no automatic detection if data changes. So you actually always have to manually update the chart / rerender. Generally there are two ways: one is over events, the other is over the watcher (the mixins are using it) However it can be, that you have to add deep: true to the watcher, because if the data is rather complex it would not see a change. Thanks for the jsfiddle. Eh, there are two mixins reactiveProp and reactiveData. You should use reactiveData only if you store your chartdata into a variable in the data function. Thats for, if you get your data over an api. If you pass your chartdata as a prop like in your jsfiddle, you should use the reactiveProp mixin. vue-routerNever used it with vue-router. Do you have a minimal repo to reproduce the error? Hard to debug it without seeing the code. |
Thnx alot for the info, I'll try to post my code with vue router, ATM I am sick but will do that when I've got a chance, solved all problems BTW with events, added update chart upon event because the mixins somehow didn't work, plus my update chart function basically does, context= chart-id, new chart (context, data) and it worked |
Thnx for the repo, you are awesome |
Did you tried both mixins? Also the What are you doing, is creating a new chart instance if new data arrives. You actually need only to call |
thank you for the info, will try it and update you, still sick :( |
hi, i tried this._chart.update() works good |
thank you |
Ok, cool. |
Yes thank you
…On Jan 12, 2017 1:23 PM, "Jakub" ***@***.***> wrote:
Ok, cool.
So can this issue be closed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#28 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEIxUFZTI62hVCpudTxv1tl82XqNbHfTks5rRg1KgaJpZM4LdrpG>
.
|
cant get to make the reactive prop to update the chart although it shows that the data has been changed the chart wont update or redraw
can anyone please post example , btw iam on vue 2.1
The text was updated successfully, but these errors were encountered: