question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All nodes are accumulated in one position.

See original GitHub issue

When creating a path using dagre, the whole nodes accumulate in one position. How can we set default positions for nodes ( Cytoscape js without react works fine) instead of setting position separately using position attribute for nodes.

const layout = { name: “dagre”, rankDir: “LR” } pageData = < CytoscapeComponent elements = { CytoscapeComponent.normalizeElements({ nodes: nodess, edges: edgess, layout: layout, }) } pan = { { x: 200, y: 200 } } autounselectify = { true } userZoomingEnabled = { false } boxSelectionEnabled = { false } style = { { width: “1200px”, height: “1000px” } } /> return ( < div

{ pageData } < /div> );

/------------------------------/ Expected Result Expected Result

Current Result Current-Result

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
TheDahvcommented, Mar 11, 2020

I encountered something similar. I found a workaround but I don’t know if it’s a bandaid because I’m doing it wrong or not.

Effectively, I used the graph event hooks to call the layout function as nodes were added. Try this and see what works for you. Maybe it will uncover or yield insight into how it’s meant to be done:

<CytoscapeComponent
  cy={cy =>
    cy.on('add', 'node', _evt => {
      cy.layout(layoutOptions).run()
      cy.fit()
    })
  } 
/>
1reaction
EdwinSmulderscommented, Jul 31, 2020

What worked really well for me is this:

                    cy.on('resize', _evt => {
                        cy.layout(layoutOptions).run()
                        cy.fit()
                    })

This will run the layout the first time it configures the size, which is apparently after the nodes have been added. This is way more performance friendly than running it on every node add.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Cytoscape JS : All nodes are accumulated in one position
When creating a path using dagre, the whole nodes accumulate in one position. How can we set default positions for nodes ( Cytoscape...
Read more >
Controlling User Interaction on Nodes - Apple Developer
Enable user interaction on every node you want the user to interact with, and subclass them to implement their responder functions. Catch All...
Read more >
Sum of the nodes of a Singly Linked List - GeeksforGeeks
Time Complexity: O(N), N is the number of nodes in a linked list. Auxiliary Space: O(1).
Read more >
Geometry Nodes - Blender Developer Wiki
The result of a field at a certain index can be calculated with the Field at Index node (b88a37a490). · The new Accumulate...
Read more >
Nodes and Edges - PGF/TikZ Manual
For this, TikZ collects all nodes defined on the current path with this option ... Now, when you place a node at a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found