user3902443
user3902443

Reputation: 39

cannot read property 'neighbours' of undefined

http://jsfiddle.net/eM6jU/200/

Uncaught TypeError: Cannot read property 'neighbours' of undefined.

it is emanating from the following loop, any idea why is this happening? cola.js line 3332

**Watch Expressions**

    "i ": Object
    length: 144
    source: "ds"
    target: "sdf"



 while (i--) {   var e = this.es[i];
    var u = getSourceIndex(e), v = getTargetIndex(e);
    var d = getLength(e);
    this.neighbours[u].neighbours.push(new Neighbour(v, d));
    this.neighbours[v].neighbours.push(new Neighbour(u, d));`

            }

Upvotes: 2

Views: 750

Answers (1)

colelemonz
colelemonz

Reputation: 1329

The solution is found in this issue submitted by OP.

Basically, cola.js expects the links to be a certain format, namely the source and target attributes need to be indexes into the node array (not the names of the nodes). Here is an example of some properly formatted data:

{
    "nodes": ["Node A", "Node B", "Node C"],
    "links": {
        {"source": 0, "target": 1},
        {"source": 1, "target": 2},
        {"source": 2, "target": 0}
    }
}

Upvotes: 0

Related Questions