mbostock/d3 — pull request #800 by GerHobbelt (2012-09-05 21:44:35+00:00)
Title: force layout: charge and friction are now functors, which allow for prod...

...ucing a per-node friction and/or charge value on every 'tick'; when possible, the charge callback (if one was specified) receives a reference to the constructed quadtree as a third argument: there is no need to have the user construct a costly second quadtree on every tick.

http://bl.ocks.org/3616279 and several other gists of mine can be simplified to using a single force instead of layering two of those on top of one another, when this (and gravity as per-node functor) is done. The interface does not change, thanks to the use of these functors, but the ability of the force layout increases a lot.

The only place where this reduces performance, is in the non-standard case where charge was specifically set to ZERO: now the quadtree is constructed anyhow and the total charge is now calculated (absolute value sum), which is extra work for that situation; anybody else should observe about the same performance.