Search code examples
cytoscape.jscytoscape

Automatic positions in Cytoscape graph for the nodes


I have JSON of nodes with data but no positions. I would like to automatically create the graph based on the edges and parent json without giving the positions. It does that but all the nodes are over the top of each other.

https://stackblitz.com/edit/angular-kpnys1?file=src%2Fapp%2Fdemo_test.json


Solution

  • You are using the preset layout, as you can see in the docs, it puts nodes in the positions you specify manually.

    If you want to use layouts with automatic positioning, please use any other layout cytoscape.js provides (except null layout).

    The docs provide detailed descriptions about the core layouts, but there are also layout extensions with some cool features here.