admin管理员组文章数量:1313292
I'm working with d3's force layout and trying to find a simple way to identify when the layout has reached a steady state (i.e. when the tick function has stopped manipulating the position of nodes).
My definition of force looks like this...
var force = d3.layout.force()
.friction(frictionValue)
.theta(thetaValue)
//.alpha(0.1)
.size([width, height])
.gravity(gravityValue)
.charge(chargeValue)
.on("tick", tick);
Then the tick function begins...
function tick(e) {
...
I assumed that "e" would be key to catching the end-point of the simulation, but since I'm not explicitly passing e to the tick function on my force definition I'm not really sure what it represents or how I might be able to use it to identify the end of the simulation. Can anyone either shed light on the function of e (since I'm not explicitly passing it a value), or even suggest a better method to do something as simple as display an "alert(..)" message once the force layout simulation has ended?
Huge thanks in advance for any help at all!
I'm working with d3's force layout and trying to find a simple way to identify when the layout has reached a steady state (i.e. when the tick function has stopped manipulating the position of nodes).
My definition of force looks like this...
var force = d3.layout.force()
.friction(frictionValue)
.theta(thetaValue)
//.alpha(0.1)
.size([width, height])
.gravity(gravityValue)
.charge(chargeValue)
.on("tick", tick);
Then the tick function begins...
function tick(e) {
...
I assumed that "e" would be key to catching the end-point of the simulation, but since I'm not explicitly passing e to the tick function on my force definition I'm not really sure what it represents or how I might be able to use it to identify the end of the simulation. Can anyone either shed light on the function of e (since I'm not explicitly passing it a value), or even suggest a better method to do something as simple as display an "alert(..)" message once the force layout simulation has ended?
Huge thanks in advance for any help at all!
Share Improve this question asked Jun 2, 2015 at 18:23 d3wannabed3wannabe 1,3172 gold badges23 silver badges40 bronze badges1 Answer
Reset to default 10You're almost right, just tick is the wrong event, you want end. So change your last line to
.on("end", function (){
// some code
});
You can read about this in the API documentation for the force layout https://github./mbostock/d3/wiki/Force-Layout
本文标签: javascriptd3 quotendoftickingquot event for force layoutStack Overflow
版权声明:本文标题:javascript - d3 "end-of-ticking" event for force layout - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741910999a2404442.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论