D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
cbertelegni
Full window
Github gist
Ellipse d3js
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;position:fixed;top:0;right:0;bottom:0;left:0; } .ellipse-bg { fill: none; stroke:#000;stroke-width:1px} .ellipse-data { fill: green; stroke: none;} </style> </head> <body> <script> var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500) let minMax = [1, 10] let scaleX = d3.scaleLinear().domain(minMax).range([10, 50]) let scaleY = d3.scaleLinear().domain(minMax).range([8, 25]) console.log(scaleX(10)) svg.append("ellipse") .attr("cx", 150) .attr("cy", 100) .attr("rx", 50) .attr("ry", 25) .attr("class", "ellipse-bg") let n = 5 svg.append("ellipse") .attr("cx", 150 + scaleX.range()[1] - scaleX(n)) .attr("cy", 100) .attr("rx", scaleX(n)) .attr("ry", scaleY(n)) .attr("class", "ellipse-data") </script> </body>
https://d3js.org/d3.v4.min.js