0

I'm trying to create force directed graph with D3.js, the data is loaded from Json file. My main goal right now is to create the nodes with fixed coordinates from beginning.

Right now d3 is building the graph in a random way. I want to decide on nodes locations before the graph is builded.

I'm using v2 , http://d3js.org/d3.v2.min.js?2.9.3

I tried added fx and fy attributes for nodes in the Json

some code can be found at: https://pastebin.com/VtKdvADF
  • Can you add parts of the code in here? – Rot-man Mar 28 '19 at 17:09
  • https://pastebin.com/Mk0v8rsS , this is the full js code. thanks. – Alexander Chinyan Mar 28 '19 at 17:12
  • Including the code in the question is generally advised - links are prone to breaking and SO seeks self contained questions (you also don't have much code so bringing it into the question should not be to overwhelming to the reader, you could also build a working snippet in the question showing the force layout as it is currently). Also, that version of d3 is almost 6 years old, you may get more answers, or find more resources/answers if you update to d3v4+, or at least v3 (as documentation for v2 is sparse). – Andrew Reid Mar 28 '19 at 17:15
  • Ok thanks, I'm new to this. I have no problem to upgrade the d3 version – Alexander Chinyan Mar 28 '19 at 17:18
  • If using d3v3 or v2, and you are seeking to fix coordinates, you can use `d.fixed = true`, see this [answer](https://stackoverflow.com/a/10400060/7106086). *I've never tested this on v2, but the answer predates the version you are working with and comes from Bostock, so I'm sure it works* – Andrew Reid Mar 28 '19 at 17:19

0 Answers0