score:1
Accepted answer
Update: position of the Links need to be calculated by new radian considering offset, like:
let parent = connection.parent;
const sx = parent.source.x;
const sy = parent.source.y;
const tx = parent.target.x;
const ty = parent.target.y;
const radiusSource = parent.source.radius;
const radiusTarget = parent.target.radius;
let radian = Math.atan2(ty - sy, tx - sx);
let offset = 0.1 // Offset ratio of radian, can be adjusted
let offsetRadian;
let angle = radian * 180 / Math.PI;
let opposite = Math.abs(angle) > 90;
if (opposite) {
angle -= 180;
offsetRadian = radian * (1 + offset);
} else {
offsetRadian = radian * (1 - offset);
}
let x1 = sx + Math.cos(offsetRadian) * radiusSource;
let y1 = sy + Math.sin(offsetRadian) * radiusSource;
let x2 = tx - Math.sin(offsetRadian) * radiusTarget;
let y2 = ty - Math.cos(offsetRadian) * radiusTarget;
connection.coords = [x1, y1, x2, y2, angle, opposite];
return connection.coords;
Source: stackoverflow.com
Related Query
- parallel links between nodes
- Drawing multiple links between fixed nodes
- The links between the nodes in Force-Directed Graph in D3 Javascript
- d3.js Links between nodes not rendering as lines
- How can I draw links between nodes with D3.js?
- d3 force layout fixed links between nodes
- Creating links between nodes d3.js currently returning Uncaught TypeError: Cannot read property 'weight' of undefined
- D3 js links length between image nodes
- Cannot display links between Nodes in D3.JS and Angular Typescript
- d3 Force: Calculating position of text on links where links between nodes are arcs
- Unpredictable Lengths Of Links between Nodes
- d3.js - Steady links between nodes on force diagram
- Add links between gray nodes - Directed Graph Editor d3.js
- D3 Tree Layout Separation Between Nodes using NodeSize
- Simple graph of nodes and links without using force layout
- Drawing multiple edges between two nodes with d3
- d3.js: "Cannot read property 'weight' of undefined" when manually defining both nodes and links for force layout
- Avoid collision between nodes and edges in D3 force layout
- How to increase distance between child nodes in a D3 Collapsible Tree?
- D3.js Adding links between elements in a radial tree (Hierarchical edge bundling elements)
- D3 force layout: links and nodes --- z-index(?)
- Increasing gap between nodes of my D3 tree layout
- How to display and hide links and nodes when clicking on a node in D3 Javascript
- How to change the distance between nodes in a force layout?
- How to check d3 js force graph for nodes with no links and remove them?
- D3 force graph rendering nodes and links
- Links and Arrowheads to terminate at borders of nodes in D3
- Converting nodes and links to hierarchical tree in d3.js
- How do you customize the d3 link strength as a function of the links and nodes counts ? (d3 v4)
- Speed up d3 force layout with many nodes and links
More Query from same tag
- How can i set the x axis tick interval to be 1 in C3 / d3 js charts?
- How to interprete Web Audio API getByteFrequencyData 0 values?
- Pattern for using Meteor with advanced SVG or Canvas Ouput
- How to enhance D3.js 'smooth scrolling' demo?
- Overwriting of labels in D3 bar chart
- How do I convert an svg file from inkscape to geoJson format
- D3 d3.text request function bug
- How is this fluent D3 method call possible?
- Horizontal Bar chart Bar labels in D3
- Multi-series chart - time (year) interval x-axis overlaying multiple years of data
- D3.zoom jumps when using mouse wheel after programmatically zoom
- Setting color of marker-end arrow in D3.js
- Making a graph inside a leaflet popup using geoJson data
- D3: GeoMapping Visualization -- Can't get anything on localHost page
- D3.js charts placed in a bootstrap carousel
- Reach a specific class with selectAll()
- Svg brush as slider. How to set slider scale graduation frequency
- D3 Domain Values Go Over Range
- Dynamically Update Styling on Button Click, D3 Bar Chart
- D3 changing X Axis on zoom
- How to find out what can be exported from npm package
- d3.js chart object error: "Uncaught SyntaxError: Unexpected identifier"
- d3 real time line chart with labels
- D3.js Barchart, split text
- Can D3.js fetch in data using "whitespace" separated values?
- Adding and removing elements from D3 Visualization with animation
- Get the element which triggered the event in d3.js
- Transition not working
- D3, Change the style of collapsible tree attribute
- Assigning two class names from functions in D3