score:14
From the documentation:
force.linkDistance([distance])
If distance is specified, sets the target distance between linked nodes to the specified value. If distance is not specified, returns the layout's current link distance, which defaults to 20. If distance is a constant, then all links are the same distance. Otherwise, if distance is a function, then the function is evaluated for each link (in order), being passed the link and its index, with the this context as the force layout; the function's return value is then used to set each link's distance. The function is evaluated whenever the layout starts. Typically, the distance is specified in pixels; however, the units are arbitrary relative to the layout's size.
Note that the link distance is still adjusted as the layout runs. You may also find setting linkStrength()
useful.
score:7
Just two steps:
Step1: Add a parameter in main json as follows:
{source: "Microsoft", target: "Amazon", type: "licensing", value: 60}, {source: "Microsoft", target: "HTC", type: "licensing",value: 60}, {source: "Samsung", target: "Apple", type: "suit",value:60},
Step2: Update linkdistance to accept method.
.linkDistance(function(d) { return d.value; })
Source: stackoverflow.com
Related Query
- Does d3.js force layout allow dynamic linkDistance?
- Relation between LinkDistance and LinkStrength in D3.js Force layout
- Dynamic Link Distance in D3 force layout
- d3.js: Does force layout only work with circles?
- d3.js force layout increase linkDistance
- why does my d3 force layout explode
- d3 dynamic curved line in force layout
- DOM does not represent the html structure of d3 force layout
- Why does the d3 force layout seem to crash and how should I overcome it?
- D3 force layout forceY does not map to range
- Maintain a dynamic link distance among nodes in force layout D3.js
- Is there a way to zoom into a D3 force layout graph?
- Fix Node Position in D3 Force Directed Layout
- How to make force layout graph in D3.js responsive to screen/browser size
- Calm down initial tick of a force layout
- Why does d3.js v3 break my force graph when implementing zooming when v2 doesn't?
- Updating links on a force directed graph from dynamic json data
- D3 force directed layout with bounding box
- Simple graph of nodes and links without using force layout
- d3.js force layout auto zoom/scale after loading
- How to update elements of D3 force layout when the underlying data changes
- d3.js: "Cannot read property 'weight' of undefined" when manually defining both nodes and links for force layout
- D3 force layout - linking nodes by name instead of index
- Display an arrow head in the middle of D3 force layout link
- D3 force layout visualization dead slow when using a large dataset?
- D3: Using force layout for word clouds
- Avoid collision between nodes and edges in D3 force layout
- Saving and reloading a force layout using d3.js
- d3.js: suggested node position in force layout
- Charge based on size - d3 force layout
More Query from same tag
- TypeScript D3 v4 import not working
- Native d3.js methods to save / store / write data to a database?
- Adding Error Bars to Grouped Bar Chart with D3.js
- What does this function in script do?
- How to implement a jointplot using d3js
- Complex d3.nest() manipulation
- Center SVG <tspan> elements when surrounding <text> element has text-anchor=start
- d3 make a force-directed-tree layout into a circle shape
- How to use a svg inside a svg?
- Mapping in d3 ordinal scales
- how can I exclude an element from an Angular scope?
- Hyperlinks in Treemap Layout
- Why tickSubdivide not working in d3js V 3.5.5 but working in d3js V2?
- D3 Coding Order
- How to get Component reference(this) in D3 Context Menu OnOpen and OnClose
- D3js drag() returns strange results on chrome
- Scaling a div tooltip in a d3 force diagram
- How to create stacked row chart with one row with dc.js?
- How to put a break point in text in d3.js
- select function not working in 3.5.4 version of d3.js
- How do I make a chloropleth based on zip codes?
- Updating D3.js graph on mouseover event
- Fix x-axis position in scrollable Heatmap d3
- Creating a heatmap of two different types for d3
- d3v4 Zoomable Treemap - how to avoid overlay of child rects?
- Trouble installing with d3-context-menu with bower using VS code
- Get the type of element in a selection
- How to update a D3 pie chart
- D3.js .rangeBands() returning 'undefined' with only the last value?
- d3.js: Converting Months to Quarter