简体   繁体   中英

D3: Lag update on force layout links when dataset changes

The "data 15000" button changes the dataset to another one that has the same nodes, but more linkages between nodes. However, the user has to click twice in order to fully display the updated force layout.

Why is this line of code 1-click late?

link.enter().append("line")
    .attr("stroke-width", function (d) { return scale(d.value); });

How do I solve this problem? Thank you!

JSFiddle here

The problem, basically:

在此处输入图片说明

Please add selection to tick function:

function ticked() {
    var link = linkg.selectAll("line")
    var fnode = fnodeg.selectAll("circle")
    ... update attributes for link(line) and fnode(circle).

working code here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM