I would like to create a graph where nodes have suggested positions, but I would also like to use the force layout to ensure the nodes themselves don't overlap. Is this possible in d3?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, you can do this by:
- Disabling the default gravity and charge forces.
- Implementing collision detection.
- Implementing "custom" gravity that attracts each node to its suggested position.
Here's a live example:
- http://bl.ocks.org/1804919
Similar techniques were used in Shan Carter's visualization of Obama's 2013 budget proposal, which are further discussed in a tutorial by Jim Vallandingham.