简体   繁体   中英

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. I can just change the name of what JSON is read in the HTML file

<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.

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/ '

but I wish to do something similar on a force directed graph

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

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

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