What do the nodes, groups, and values ​​in JSON mean for the d3 syntax graph?

I am trying to create a d3-oriented diagram ( http://mbostock.github.com/d3/ex/force.html ). Here is a simple JSON file containing my data.

{"nodes":[{"name":"Node1","group":1}, {"name":"Node2","group":1}],

    "links":[{"source":1,"target":2,"value":2}]}

I have two nodes in one group. I am also trying to create a connection between these two nodes. However, my page remains blank (and I am sure that other parts than JSON are correct).

What is a "group"? Why do borders have both a "source" and a "target" - and what are these meanings? Why are links “valuable”? Are links not just unweighted edges? I'm having trouble understanding the JSON data storage structure.

+5
source share
1 answer

In a d3-oriented graph, the example of the value of the “value” of the links is mapped to the width of the line of edges and the “group” of nodes is mapped to the color of the nodes. The integer value “source” and “target” in the links refers to the index of the array of the corresponding node in the nodes ( https: // github.com/mbostock/d3/wiki/Force-Layout#wiki-links ).

If you change the source links to

 "links":[{"source":0,"target":1,"value":2}]}

it, d3 should display an edge between two nodes.

+8
source

All Articles