force-layout

Labels / text on the nodes of a D3 force directed graph

[亡魂溺海] 提交于 2020-08-22 04:33:10
问题 I still not understanding why the code bellow does not display its labels / text... I have defined the css and set the attribute like the title when the move is over the node: Json: { "nodes":[ {"name":"t1","group":1}, {"name":"t2","group":1}, {"name":"t3","group":1}, {"name":"t4","group":1}, {"name":"hate","group":2}, {"name":"good","group":2}, {"name":"aiport","group":3}, {"name":"flight","group":3} ], "links":[ {"source":0,"target":4,"value":4}, {"source":0,"target":5,"value":4}, {"source"

Confining force layout's groups of nodes to area of SVG element in d3

こ雲淡風輕ζ 提交于 2020-08-10 18:16:47
问题 I'm working on a d3 visualization, and I'd like to have a tiered system of three circles to confine the nodes of a force layout. A group of nodes would be confined to the space between the previous smaller circle and the next larger one. My code: var width = 600; var height = 600; var svgContainer = d3.select("body").append("svg") .attr("width", width) .attr("height", height); var force = d3.layout.force() .gravity(.05) .distance(100) .charge(-100) .size([width, height]); var cir_arr = [];

Confining force layout's groups of nodes to area of SVG element in d3

巧了我就是萌 提交于 2020-08-10 18:15:24
问题 I'm working on a d3 visualization, and I'd like to have a tiered system of three circles to confine the nodes of a force layout. A group of nodes would be confined to the space between the previous smaller circle and the next larger one. My code: var width = 600; var height = 600; var svgContainer = d3.select("body").append("svg") .attr("width", width) .attr("height", height); var force = d3.layout.force() .gravity(.05) .distance(100) .charge(-100) .size([width, height]); var cir_arr = [];

d3v4 force chart upgrade clean up

房东的猫 提交于 2020-07-19 04:40:48
问题 I have some old relationship type - force chart from version 3 of d3. I am keen to clean up and reduce the codebase -- reduce the reliance on all the functions. I had to refactor the data set and make nodes. I have started trying to port the code - but now running into upgrade errors- "d3.force is not a function" looking at this as a reference D3 forceSimulation and dragging, what is node.fx/node.fy? keen to fix the upgrade refactor to make the creation of this chart easier and simpler -

How to change the distance between nodes in a force layout?

↘锁芯ラ 提交于 2020-06-13 06:20:08
问题 I am new to D3 and try to learn force layout. I want to change the link distance between nodes and maintain the origin shape. I find that after I change the distance of the links, the layout was changed. Figure one is the original layout, then I changed the link distance with code distance([150]) (at line 80) to make the nodes further, but the layout changes out of my expectation. I expected it the layout will grow up with keeping the shape as same as original, but the layout changes a lot. I

How to get the same node positions in d3's force layout graph

风格不统一 提交于 2020-04-13 18:04:48
问题 I would like to create a force directed graph, but i need it to stay the same every time it is generated (with the same data). Is there any way to do this using d3.js? UPDATE: I found working solution, which is based on using seeded random number generator // set the random seed Math.seedrandom('mySeed'); 回答1: You could by modifying D3's force layout, or by creating your own layout based on it. There are at least 3 places where randomness (Math.Random) is used in the positioning of nodes

Move d3 circles away from center circle - force layout

心已入冬 提交于 2020-02-01 07:26:28
问题 I'm working on d3 to represent nodes in circles, when the size of a circle is changed then the circles around them should move away from the one's size got changed from being overlapped. Consider the red circle above, when its size get changed then the others should move in the green arrow's direction. I tried with force simulation but I'm not able to achieve it and added the code below, I'm not sure what I'm doing wrong, can somebody help please? https://jsfiddle.net/m6s8dk7o/29/ var w = 900

Move d3 circles away from center circle - force layout

柔情痞子 提交于 2020-02-01 07:26:25
问题 I'm working on d3 to represent nodes in circles, when the size of a circle is changed then the circles around them should move away from the one's size got changed from being overlapped. Consider the red circle above, when its size get changed then the others should move in the green arrow's direction. I tried with force simulation but I'm not able to achieve it and added the code below, I'm not sure what I'm doing wrong, can somebody help please? https://jsfiddle.net/m6s8dk7o/29/ var w = 900

Adding text labels to force directed graph links in d3.js

巧了我就是萌 提交于 2020-01-25 20:34:05
问题 I am having trouble adding a text to the links that connect the nodes in the following D3JS connected node graph: http://jsfiddle.net/rqa0nvv2/1/ Could anyone please explain to me what is the process to add them? var link = svg.selectAll(".link") .data(links) .enter().append("line") .attr("class", function(d) { if(d.value == "visible") {return "link";} else return "" }) .style("stroke-width", function(d) { return Math.sqrt(d.stroke); }); link.append("svg:title").text(function(d) { return

Place pie charts on nodes of force directed layout graph in D3

帅比萌擦擦* 提交于 2020-01-19 12:53:10
问题 I would like to place pie charts on the node of a D3 force directed layout graph using D3.js. This is a common visualization in population genetics, see for example http://mathildasanthropologyblog.files.wordpress.com/2008/06/as3.jpg I've started with a very basic graph plot: <!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript" src="d3/d3.v3.js"></script> </head> <body> <script type="text/javascript"> graph = { "nodes":[{"proportions": [{"group": 1, "value": 1}, {"group": 2,