简体   繁体   English

如何动态更改力布局图中的数据? D3

[英]How to change the data in a force layout graph dynamically ? D3

I have a few JSON files I can use with my force directed graph and I wish to choose which one I run. 我有一些JSON文件可以与强制方向图一起使用,我希望选择运行哪个JSON文件。 I can just change the name of what JSON is read in the HTML file 我可以更改HTML文件中读取的JSON的名称

<script type="text/javascript" src="networkA.json"></script>

to

<script type="text/javascript" src="networkB.json"></script>

but I wish to do this dynamically. 但我希望动态地做到这一点。

So when I first load the SVG my choice of data pops up and I get to choose which one I want the force directed graph to run off. 因此,当我第一次加载SVG时,会弹出我选择的数据,然后选择要让力导向图运行的数据。

Also, wish to change this when its running, but knowing how to do the start up will probably answer that question. 另外,希望在运行时更改此设置,但是知道如何进行启动可能会回答该问题。

Here is a perfect demo that can change dynamically: 这是一个可以动态更改的完美演示:

' http://projects.flowingdata.com/tut/interactive_network_demo/ ' ' http://projects.flowingdata.com/tut/interactive_network_demo/ '

but I wish to do something similar on a force directed graph 但我想在力向图上做类似的事情

使用d3.json根据用户界面选择动态加载数据,如下所示:

https://github.com/mbostock/d3/wiki/Requests

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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