D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ezzaouia
Full window
Github gist
2 scales filled circle & circle
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; } </style> </head> <body> <script> // Feel free to change or delete any of the code you see in this editor! const width = 960, height = 500; var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) .append('g') .attr('transform', `translate(${100}, ${height/2})`); let data = [{key: 'key1', k: 12, d: 45, c: '#D50000' }, {key: 'key2', k: 23, d: 34, c: '#64DD17' }]; let g = svg.selectAll('key') .data(data) .enter() .append('g') g.append("circle") .attr("r", d => d.d) .attr("cx", (d, i) => i*79) .style("stroke", d => d.c) .style("stroke-width", 2) .style("fill", 'none') svg.append('line') .attr('x1', 0) .attr('x2', 100) .attr('y1', 0) .attr('y2', 0) .style('stroke', '#555') .style('stroke-width', 20) .style('stroke-linecap', 'round') </script> </body>
https://d3js.org/d3.v4.min.js