tgdwyer / WebCola

Javascript constraint-based graph layout
http://marvl.infotech.monash.edu/webcola/
MIT License
2.02k stars 258 forks source link

Reapplication of cola.groups leads to reference to property of undefined #140

Open waTeim opened 9 years ago

waTeim commented 9 years ago

It appears that .groups can not be re-applied to an array.

This bug can be illustrated using this .html gist; it is an adaptation of a WebCola example.

The error that is raised is

Uncaught TypeError: Cannot set property 'parent' of undefined
    (anonymous function) @ powergraph.ts:1
    (anonymous function) @ powergraph.ts:1
    a.adaptor.n.groups @ powergraph.ts:1
    (anonymous function) @ bug.html:72
    (anonymous function) @ d3.v3.js:1052

For immediate context

        cola
          .nodes(G.graph.nodes)
          .links(G.graph.links)
          .groups(G.graph.groups)   <--- line 72
          .constraints(G.graph.constraints)
          .start(10,10,10);

What appears to be happening is that even though group members are valid (it has been set previously) they are re-set to undefined if cola.groups is invoked on it a 2nd time.

The analogous re-application of .nodes and .links does not raise an error.

In the above example, the following is a workaround (group elements are reinitialized to the analogous node indexes).

        // uncomment for work around to bug
        //G.graph.groups[0].leaves = [0];
manacoa commented 9 years ago

+1

cedricvidal commented 8 years ago

+1

konstantin-hadzhiev commented 8 years ago

+1

tgdwyer commented 8 years ago

+1 !

yochannah commented 7 years ago

+1 Yep, I just encountered this issue :)