d3.js: suggested node position in force layout

前端 未结 1 1622
深忆病人
深忆病人 2021-01-31 06:00

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 possibl

相关标签:
1条回答
  • 2021-01-31 06:47

    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.

    0 讨论(0)
提交回复
热议问题