-
Notifications
You must be signed in to change notification settings - Fork 1.5k
vis.js Network & Vue.js - the setData method is not working properly #2524
Comments
Can you reproduce the problem without using Edit: Looks like this works without |
@Tooa Yeah, this works without Vue, but can't see why it doesn't work with Vue. Anyway, it seems that this has nothing to do with Vis. Thanks! |
I debugged this issue the last three hours without success. However, I got some insights and I want to share here with you: The rendering for the node labels is called here. The This all seems to work fine. However, for some strange reasons later on the value of |
@Tooa I'm not sure but I believe that the problem is not in Vis but in how Vue's reactivity works. From the Vue documentation:
... so I guess that the answer lies here:
I put the whole Vis instance in the Vue data... but I am still not sure if this is the reason. I overcame this problem by moving Vis out of Vue, and now I am using "centralized event hub" to communicate with Vue: https://jsfiddle.net/9cpqjs9h/ |
if And one more thing, with babel preprocessor enabled in codepen - doesn't work. |
A workaround hack is to attach it to the global window object and avoid vue.js observer all together: Here is working example: http://codepen.io/anon/pen/pepavJ |
@kolarski Why is this a hack? I think moving the |
Attaching Vis nodes, edges, data, options, network... to the global window object and using "centralized event hub" to communicate with Vue is what I did in my project: https://github.com/FilipQL/OVS-Mesh-Script-Generator entry (src / main.js):
src / App.vue:
|
Hi,
I am using Vis Network with Vue.js and I created a very simple app but it is not working properly.
https://jsfiddle.net/Filip_Z/3ead4r51/1/
The problem is that after applying the
setData
method, wrong labels are displayed. As you can see in the example, when you click on the button - this Vue method will be executed:So there will be three nodes but, for some reason, all these nodes will have the same label: '4'.
In the browser console there are no errors.
Now, I'm not sure where the problem is (Vue or Vis).
The text was updated successfully, but these errors were encountered: