gpt4 book ai didi

javascript - D3.js 中的 Spring Forces Force 定向布局?

转载 作者:行者123 更新时间:2023-11-29 15:42:19 24 4
gpt4 key购买 nike

这个例子的描述:http://bl.ocks.org/mbostock/4062045 (见下图),声明它是“带电粒子和 Spring 的物理模拟,使相关 Angular 色更接近。”

enter image description here

我只是好奇该代码的哪一部分(在同一页面上)实现或定义了 Spring 力,尤其是基于相关字符?

我问这个是因为我的印象是 D3.js 没有为力定向布局实现 Spring 力,如其 API 文档中所述:

“链接不是像其他力导向布局中常见的那样作为“ Spring 力”实现的,而是作为弱几何约束实现的。” - https://github.com/mbostock/d3/wiki/Force-Layout#wiki-linkDistance

最佳答案

在 D3 力导向布局中, Spring 力使用 gravity 方法定义,如果未设置则默认为 0.1

查看 this fiddle你提到的同一个例子,重力设置为 0.9

linkDistance 文档中提到的“弱几何约束”被进一步讨论 here .

"gravity is implemented as a weak geometric constraint similar to a virtual spring connecting each node to the center of the layout's size. "

关于javascript - D3.js 中的 Spring Forces Force 定向布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17355072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com