force-layout

D3 force layout: Straight line instead of curve for links (but only for some links)

爱⌒轻易说出口 提交于 2019-12-19 21:25:07
问题 I have this D3 jsfiddle that produces following diagram: The only thing that bothers me about this diagram is that if there is only one link between two nodes, it is drawn as a curve. I think it would be much better if such links were just straight lines (arrow would be fine). Let's say between Microsoft and Amazon should be just a straight line (with arrow). The same between Oracle and Google, Sony and LG, etc. How to achieve this? 回答1: It's very easy. In your linkArc(d) method, just set the

D3 force layout: links and nodes — z-index(?)

别说谁变了你拦得住时间么 提交于 2019-12-19 18:36:15
问题 D3: problems between nodes and links I created the following jsfiddle to get an idea of what i'm trying to achieve: I want nodes to over(?) links... Please help me. I'm sorry for my English :) Script looks like this: function myGraph(el) { this.addNode = function (id) { nodes.push({ "id": id }); update(); } this.removeNode = function (id) { var i = 0; var n = findNode(id); while (i < links.length) { if ((links[i]['source'] == n) || (links[i]['target'] == n)) links.splice(i, 1); else i++; }

d3js create a force layout with fixed nodes [closed]

怎甘沉沦 提交于 2019-12-19 17:37:10
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . i've implemented this http://jsbin.com/omokap/3/edit: However, I would like to cancel the dynamic behavior of the graph (like in the dragend state, but that is only for the single node) and place the nodes in the set points, taken from json. I've see this questions Moving fixed nodes in D3 and Fix

d3.js linkStrength influence on linkDistance in a force graph

给你一囗甜甜゛ 提交于 2019-12-19 10:22:12
问题 I'm working on a graph to show relations between different nodes. The closer related the nodes are (according to business logic), the closer together the nodes should be. I noticed that some links with the linkStrength of .1 are shorter (that is what I wanted to achieve) and some others with the same strength are longer than the ones with the linkStength of 1 . From a documentation about the force layout parameters I now found this quote: The default linkStrength value is 1.0, which maintains

d3 force collapsible layout - start page with all nodes collapsed

亡梦爱人 提交于 2019-12-19 09:44:11
问题 I just need a simple modification of the layout available here http://mbostock.github.io/d3/talk/20111116/force-collapsible.html The above visualization starts with all the nodes being expanded and so the user can visualize the complete hierarchy. The only problem is if the graph is dense, and the hairball that is formed is meaningless. I would be interested in starting with just the root node and gradually expanding all the nodes as needed. Is it feasible? How much code change is needed? 回答1

d3-force update radius of forceCollide after initializing graph

亡梦爱人 提交于 2019-12-19 08:59:31
问题 This question is a follow-up on a previous one titled "D3-Force updating parameters after initializing graph" (D3-Force updating parameters after initializing graph) and that @altocumulus answered. I am trying to update the simulation forces after modifying the radius of some nodes. However, when I call on forceCollide to account for the changes it does not work. The graph first initiates correctly, using forceCollide and a function to have the force correspond with the radius: var

How to make labels and nodes in D3 forced layout clickable to navigate to a URL?

心不动则不痛 提交于 2019-12-19 08:46:23
问题 I am using a force based layout using D3 and was wondering if it's possible that when I click either the nodes or the labels, I am automatically taken to the url stored in that node/label? If it is, how can I achieve this? This is how the graph will actually look (labels indicate the URL itself) I am sharing the javascript code I am using to generate the D3 graph. In the code, I am currently using dummy data which will actually be replaced by URLs. document.addEventListener('DOMContentLoaded'

How to make labels and nodes in D3 forced layout clickable to navigate to a URL?

雨燕双飞 提交于 2019-12-19 08:44:06
问题 I am using a force based layout using D3 and was wondering if it's possible that when I click either the nodes or the labels, I am automatically taken to the url stored in that node/label? If it is, how can I achieve this? This is how the graph will actually look (labels indicate the URL itself) I am sharing the javascript code I am using to generate the D3 graph. In the code, I am currently using dummy data which will actually be replaced by URLs. document.addEventListener('DOMContentLoaded'

How to stop a d3 force graph layout simulation?

你说的曾经没有我的故事 提交于 2019-12-19 03:38:18
问题 Once you d3.layout.force()....start() a force layout simulation in D3, it keeps on going with also an active event. I want to set a timeout of 5 seconds to let the graph force layout simulation take shape and stop ( calling .stop() or alpha(0). This works to stop, but as soon as I drag a node the simulation starts again. The following code, also on easily testable from jsfiddle, shows at the last line that the stop() will be issued and the simulation immediately stops, but as soon as you drag

Recentering D3 force layout diagram on node click

ぃ、小莉子 提交于 2019-12-19 03:11:18
问题 I am trying to create a force diagram that gets re-centered on click. I am following this as a base: I tried to adjust the click function to set d.fixed=true and also assign fixed points for d.x and d.y . However, I need to turn d.fixed=false for all the other nodes. Also, the node does not transition to the center on click. My question is how do I set all other fixed properties to false and then redraw the force diagram with the new center? I have prepared an example here: The click function