Skip to content
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

layout.avoidOverlap doesn't work properly with incremental graphs. #319

Open
kuterd opened this issue Mar 16, 2021 · 0 comments
Open

layout.avoidOverlap doesn't work properly with incremental graphs. #319

kuterd opened this issue Mar 16, 2021 · 0 comments

Comments

@kuterd
Copy link

kuterd commented Mar 16, 2021

I am making something where nodes can added and removed over time.
When the array supplied to cola.nodes is not the exact same, newly added nodes can collide with other nodes.

Example:
The node with "bug" label can overlap with other nodes.
https://jsfiddle.net/y1pwLxht/
Notice that I am cloning the array passed to the .nodes function.

        cola
            .nodes([].concat(graph.nodes))
            .links([].concat(graph.links))
            .start();

It works without the copy. This is important because I actually have to store the nodes inside a Object so I can remove them over time. And I pass the return value of Object.values to the .nodes function

Workaround I found:

this.nodeList.splice(0, this.nodeList.length);
this.nodeList.push.apply(this.nodeList, Object.values(this.graph.nodes));

cola
  .nodes(this.nodeList)
  .links(edgeList)
  .start()

The trick here is that this.nodeList is always the same array object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant