D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tomshanley
Full window
Github gist
S curve
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> var points = [[150, 50], [150, 200]] var svg = d3.select("body").append("svg") .attr("width", 300) .attr("height", 300) svg.append("path") .datum(points) .attr("stroke", "grey") .attr("stroke-width", "15px") .attr("fill", "none") .attr("d", function(d){ let x1 = d[0][0] let x2 = d[1][0] let y1 = d[0][1] let y3 = d[1][1] let yGap = (y3 - y1) let xPadding = yGap/3 let y2 = y1 + (yGap/2) let M = "M" + x1 + " " + y1 + " " let C1 = "C" + (x1 + xPadding) + " " + y1 + ", " let C2 = (x1 + xPadding) + " " + y2 + ", " let C3 = x1 + " " + y2 + " " let S = "S " + (x2 - xPadding) + " " + y3 + ", " let end = x2 + " " + y3 return M + C1 + C2 + C3 + S + end }) svg.selectAll("circle") .data(points).enter() .append("circle") .attr("cx", d => d[0]) .attr("cy", d => d[1]) .attr("r", 10) .attr("fill", "black") </script> </body>
https://d3js.org/d3.v4.min.js