d3.js: “Cannot read property 'weight' of undefined” when manually defining both nodes and links for force layout

前端 未结 6 653
旧时难觅i
旧时难觅i 2020-12-09 16:31

I tried setting both nodes and links at the same time this way:

var force = d3.layout.force()
    .size([w, h])
    .nodes(nodes)
    .links(connections)
            


        
6条回答
  •  北海茫月
    2020-12-09 17:13

    In addition to the answers mentioning the null in the source/target of links, the reason for this could be the assignment of an out-of-range source/target. E.g. you have 10 nodes and you assign the target to be the 11-th indexed node.

提交回复
热议问题