2018-04-19 星期四 晴 d3 v4 force API 翻译

Simulation

# d3.forceSimulation([nodes]) <>

Creates a new simulation with the specified array of nodes and no forces. If nodes is not specified, it defaults to the empty array. The simulator starts automatically; use simulation.on to listen for tick events as the simulation runs. If you wish to run the simulation manually instead, call simulation.stop, and then call simulation.tick as desired.

创建一个力的模拟器,如果nodes不传,则默认为空数组。 模拟器是自动开始模拟的,不需要你手动开始,但是如果你想手动开始模拟,则可以调用simulation.stop()和similation.tick()

# simulation.restart() <>

Restarts the simulation’s internal timer and returns the simulation. In conjunction with simulation.alphaTarget or simulation.alpha, this method can be used to “reheat” the simulation during interaction, such as when dragging a node, or to resume the simulation after temporarily pausing it with simulation.stop.

restart 重新调用模拟器内部的定时器重新模拟

# simulation.nodes([nodes])

冷却系数,当冷却系数小于设置的最小冷却系数的时候,simulation停止布局完成
simulation.velocityDecay([decay])
If decay is specified, sets the velocity decay factor to the specified number in the range [0,1] and returns this simulation. If decay is not specified, returns the current velocity decay factor, which defaults to 0.4. The decay factor is akin to atmospheric friction; after the application of any forces during a tick, each node’s velocity is multiplied by 1 - decay. As with lowering the alpha decay rate, less velocity decay may converge on a better solution, but risks numerical instabilities and oscillation.
设置节点的速度衰减的快慢,如果设置过大的时候,节点就会很快进入到稳定状态,但是这样可能节点不会处于最恰当的位置,这点和冷却系数有点一样。

manyBody.theta([theta]) <>
用来指定计算精度的

你可能感兴趣的:(2018-04-19 星期四 晴 d3 v4 force API 翻译)