score:1
Accepted answer
The easiest way to do this is with a path string:
var s = 10 //grid size
var p0 = [10, 15] //start point
var p1 = [20, 25] //end point
var connectionPath = svg.append('path')
.attr('d', [
'M', p0[0]*s, p0[1]*s, //put pen at start point
'H', p1[0]*s, //move pen horizontally
'V', p1[1]*s //move pen vertically
].join(' '))
.attr('fill', 'none')
.attr('stroke', '#000')
To adjust when the rectangles are dragged, update the d
attribute each time one of the rectangles is dragged.
Source: stackoverflow.com
Related Query
- How to connect a path between 2 points in a grid using D3
- How can I connect coordinate points on a map using d3js?
- How to move along a path but only between two specified path points
- How to draw a line / link between two points on a D3 map based on latitude / longitude?
- How to mark discrete points on a time series graph using D3 / Rickshaw?
- How to animate along a curved path using gravity
- How to animate an object along a GeoJSON path using d3.js?
- Draw curve between two points using diagonal function in d3 js
- How do I animate points down a path on a map in D3.js?
- How do I draw an arrow between two points in d3v4?
- How to style using d3's .style() method instead of using CSS in style tags for .axis path {}?
- How do make my plot points smooth in d3.js using projection?
- How to add some padding between a path and text on it?
- How to animate a path along with its points in d3
- How do I redraw a path using D3.js methodology?
- d3.js How to simplify a complex path - using a custom algorithm
- How can I offset the source and target points of a bezier curve using D3's link generator?
- How to draw the interactions between source and destination countries using ip address?
- How to create SVG with grid lines using D3JS
- In a d3 scatterplot using data from a csv file, how do i draw lines connecting related points when the mouse is over a point?
- how to start drawing a line with a space between y-axis and it using d3js
- how to display vertical grid with time series data using react-native-svg-charts
- How can I connect Storm and D3.js using Redis and Flask?
- How to add non linear curve between any two points of area chart in d3.js
- Drawing path trails between two points
- d3 javascript, get distance between two points in an svg path
- how to set color and grid in areaplot using d3.js?
- How to visualise the relationship between two nodes in Neo4j using d3.js?
- How to show the unhighlighted/ not selected data points on scatter plots when using brush/group in dc.js? And is multiple brushes possible in dc.js
- Line chart - how to display data points whilst line path is being drawn
More Query from same tag
- Get ISO week day and week of year in d3
- Appending path elements to an svg element without overwriting
- dc.js Access value after grouping for line chart
- Filtering by an array in D3 (filtering by array of string keywords)
- Get the center of an arc path and get the x and y that relates to in screen coords
- what is the equivalent group code for nest and group functions in D3 V6
- d.label is reading undefined on D3 Line chart
- D3 text wrap with text-anchor: middle
- Manipulating Bars
- D3 update, enter and remove
- D3 stacked bar chart with time
- How to change the X-axis line from top to bottom in d3.js
- D3.js Time series graph with epoch time
- D3.js transition callback on frame
- Show associated metric from CSV in tooltip when county is hovered
- Line charts in d3.js using d3.chart.js
- return date value of Focus+Context via Brushing Chart
- Nodes Title around a Circle
- Proper data structure for d3 nodes
- SVG textPath not visible after transition on Chrome
- D3 ticked function does not find d.target.x
- How can I get a list of tree-ancestors and tree-descendants from this d3.js layout.tree?
- Select specific elements and change style of one
- D3 empty placeholders in scaleBand?
- Cannot get D3 .on('mouseover', ...) to work
- Marimekko Chart: x axis ticks with irregular column width
- Dots with old data points do not get removed
- D3 tooltip show values from nested dataset
- D3 4.9.1 returns different value for .style("transform")
- Graphing code size