Skip to content

vis.js Network & Vue.js - not working properly #4622

@FilipQL

Description

@FilipQL

Hi,

I am using Vis Network with Vue.js and I created two very simple applications, but none of them is working properly.

1) The first app is here: https://jsfiddle.net/Filip_Z/9k2s3dgj/4/

The problem is that it cannot delete only the first node (with id=0). All of the other nodes can be deleted.

vis vue - deletenode - jsfiddle - mozilla firefox 2017-01-02 02 54 46

In the browser console there are no errors.

    Vue.component('ovs-network', {
        template: "#mytmp",
        data() {
            return {
                network: null,
                nodes: [
                    { id: 0, label: '0' },
                    { id: 1, label: '1' },
                    { id: 2, label: '2' },
                    { id: 3, label: '3' },
                    { id: 4, label: '4' }
                ],
                edges: [],
                options: {
                    manipulation: {
                        enabled: true,
                        initiallyActive: true,
                        deleteNode: function (deleteData, callback) {
                            callback(deleteData)
                        }
                    }
                },
                container: ''
            }
        },

        mounted() {
            this.container = document.getElementById('mynetwork');
            var data = {
                nodes: this.nodes,
                edges: this.edges
            };
            this.network = new vis.Network(this.container, data, this.options);
        }
    });


    const app = new Vue({
        el: '#app'
    });

2) The second app is here: 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:

                updateData() {
                    var nodes = [
                        { id: 0, label: '0' },
                        { id: 1, label: '1' },
                        { id: 4, label: '4' }
                    ];

                    this.network.setData({ nodes: nodes, edges: []});
                    console.log('Updated!');
                    this.disabled = true;
                }

So there will be three nodes but, for some reason, all these nodes will have the same label: '4'.

vis vue - dataset - jsfiddle - mozilla firefox 2017-01-02 02 58 55

In the browser console there are no errors.

Now, I'm not sure where the problem is (Vue or Vis).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions