admin管理员组文章数量:1334704
I'm using a force-directed layout in D3 that grabs data from a JSON file and then, when one of the nodes is double-clicked, queries the database to find links to that node and updates the links and nodes arrays attempting to append the new data to the viz. It seems when the nodes are appended without links, they work fine, but the links to the xy coordinates end up being NaN. You can see the effect here, just double-click on one of the nodes:
I'm using a force-directed layout in D3 that grabs data from a JSON file and then, when one of the nodes is double-clicked, queries the database to find links to that node and updates the links and nodes arrays attempting to append the new data to the viz. It seems when the nodes are appended without links, they work fine, but the links to the xy coordinates end up being NaN. You can see the effect here, just double-click on one of the nodes:
http://blockses.appspot./2432083
Share Improve this question edited Jan 19, 2014 at 9:07 VividD 10.5k8 gold badges66 silver badges112 bronze badges asked Apr 23, 2012 at 2:05 ElijahElijah 4,6393 gold badges29 silver badges36 bronze badges 02 Answers
Reset to default 9I fixed this by rewriting the code to follow the force-directed with append example from Bostock. The problem seems to occur when you overwrite your nodes and links arrays rather than pushing data to them, in case anyone runs into similar issues.
The updated code is in the original gist and can be seen here:
http://blockses.appspot./2432083
Old post, but I also hit this issue and my solution was different.
I figured out when I was setting the size of the force layout :
networkViewerVariables.force = d3.layout.force()
.gravity(.05)
.distance(50)
.charge(-50)
.size([forceWidth, forceHeight])
The 'forceWidth' and 'forceHeight' variables were null. When I populated these, the errors were gone.
Hope that helps someone :)
本文标签: javascriptNaN on ForceDirected Layout Append in D3jsStack Overflow
版权声明:本文标题:javascript - NaN on Force-Directed Layout Append in D3.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742366122a2461294.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论