This is part one of a way to use d3.js's force directed graph to create a customized static layout. Part 2 is here. The simulation first distributes all of the nodes and links according to forces and charges. Then, you can drag the nodes around to where you would want them to be in a final static image. You can also drag the purple 'intermediate' nodes around in order to specify the control points for the Bezier curve of the links.
This was largely inspired by Mike Bostock's post on his process for making the NYT Oscar Contenders graph which also uses an adjusted force directed graph layout with Bezier control points.
Once you are happy with the way your graph looks, you can click the 'print' button and a JSON object will be printed to your console. This is a quick and very dirty way to get the object- in Google Chrome you can right click on the variable through developer tools and make it global. This should yield a variable called temp1
. Then type copy(temp1)
into your console and the JSON will be copied to your clipboard. Copy that into a separate file, and read it in- see part 2 for an example of reading in a file like that one to generate a static graph. This isn't a great way to do it, but it certainly gets the job done. Feel free to fork to add better functionality!