I need to build a network of nodes and edges for a hierarchical data set. I really liked the wine and cheese sample in cytoscape.js and I am looking to implement my view in a similar fashion. I noticed that graph gets it's data from a remote api call which has the positions for each node pre-defined. Can anyone point me to some sample code which I could use to generate the positions in a similar manner?
Asked
Active
Viewed 684 times
0
-
the wine nodes are just aligned in two lines, and the cheese nodes use a plain network layout you can easily generate using what cyto already gives you out of the box. providing absolute node positions in this case is pointless as the X and Y are meaningless. – svarog Dec 09 '15 at 07:48
-
The wine and cheese demo just uses Cytoscape layouts. Since there's only one static graph, there's no advantage to running layouts dynamically each time -- so the positions are stored in the nodes. @svarog has the right approach – maxkfranz Dec 09 '15 at 16:25
-
I am not sure I understand what you mean by providing X and Y positions are meaningless, since I see the positions are specified by the api that is called within js code https://cdn.rawgit.com/maxkfranz/3d4d3c8eb808bd95bae7/raw Additionally, the layout I see is 'preset'. Doesn't that mean it uses the absolute positions? If the positions returned by the above api code are indeed used, then I am curious to know how the coordinates were generated in the first place (which might be a graph algorithm). Sample code would be useful. Thanks! – AgentHunt Dec 09 '15 at 19:13
-
For clarification, I am more interested in the cheese nodes. I am assuming the positioning is not random – AgentHunt Dec 09 '15 at 19:36
-
have you tried the cose layout ? it should provide you with a similar setup – svarog Dec 09 '15 at 20:09
-
1Any physics/forces layout. There are many supported. You'll have to experiment with different ones and different parameters to see what works best for *your* data. It's a different case for every graph. – maxkfranz Dec 14 '15 at 15:32
-
That pointed me in the right direction. I ended up using an a force layout algorithm. Thanks for the help! – AgentHunt Dec 15 '15 at 03:06