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

Randomly generate xy based on edge 'distance' length? #56

Open
jduncanRadBlue opened this issue Aug 9, 2018 · 0 comments
Open

Randomly generate xy based on edge 'distance' length? #56

jduncanRadBlue opened this issue Aug 9, 2018 · 0 comments

Comments

@jduncanRadBlue
Copy link

After digging and playing around I am having a hard time trying to specify node placement. I have a distance value that corresponds to how far away I'd like the next node to be from the main node. Is there a way to randomly place the nodes on the graph but have the edge's a certain length? So lets say for example I have this:

const graph = {
  nodes: [
      {id: 1, label: 'Home'},
      {id: 2, label: 'Node 2'},  <---this guy has a distance of 1.0
      {id: 3, label: 'Node 3'},  <---this guy has a distance of 1.2      
      {id: 4, label: 'Node 4'},  <---this guy has a distance of 1.7
      {id: 5, label: 'Node 5'}   <---this guy has a distance of 2.1
    ],
  edges: [
      {from: 1, to: 2},
      {from: 1, to: 3},
      {from: 1, to: 4},
      {from: 1, to: 5}
    ]
}

Is there a way to auto generate Node x and y values based off of the distance attribute? I'm not finding anything that will allow for me to do this.
Thanks so much!!

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