News for hackers. Stuff that matters.
Re:D3.js: Understanding the Force Layout by pachydermic on Friday July 10, 2015 @02:30PM (#9865815)
Does anyone know of any way to quickly find a steady(ish) state for the force layout? I have a complicated system with around 500 nodes and way more directed connections and the performance of rendering that system on our modest computers is terrible.

A static graph with a sane layout is what I'm after - anyone know of an efficient way to calculate the x and y positions ahead of rendering?

Thanks Obi Wan, you're my only hope.

Re:D3.js: Understanding the Force Layout by sxywu on Friday July 10, 2015 @03:13PM (#9866132)
If you need to re-generate the graph positions on every reload, the static force layout is helpful (http://bl.ocks.org/mbostock/1667139). The code of interest is: force.start(); for (var i = n; i > 0; --i) force.tick(); force.stop(); Where n is the number of iterations you want it to go through. Depending on the complexity of your graph, you may or may not arrive at optimal layout (nodes may overlap), but does calculate and render quickly.

Another key is to update positions of nodes and links only at calculation end, rather than at each tick. This means that user may have to wait a couple seconds before seeing the graph, but will save your browser from having to update the DOM at each tick (which could be thousands of times across thousands of elements).

But the best is still if you don't need to re-calculate the positions (no new nodes ever show up, and no nodes are ever deleted), going with what me_bx said.

Re:D3.js: Understanding the Force Layout by me_bx on Friday July 10, 2015 @03:04PM (#9866066)
You can render the graph once, then store the position of each node/edge. Can be done on the server, or in the browser then export the result if it's only for a one shot.