D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ezzaouia
Full window
Github gist
pos neg 2
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; const height = 500; var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) let data = d3.range(2) let g = svg.append('g') .attr('transform', `translate(${200}, ${height / 2})`); /** adding g element and rotated them around a cirlce, 360° */ g.selectAll('g') .data(data) .enter() .append('g') .attr('transform', function (d, i) { return 'rotate(' + (180 * i / data.length) + ')'+ 'rotate(-135)'; }); g.selectAll('g') .append('line') .attr('x1', 30 ) .attr('y1', 0 ) .attr('x2', 100 ) .attr('y2', 0 ) .attr('stroke-width', 30) .attr('stroke-linecap', 'round') .style('stroke', '#eee') g.append('circle') .attr('cx', 0) .attr('cy', 0) .attr('r', 20) .style('fill', '#eee') .attr('stroke', '#fff') .attr('stroke-width', 2) </script> </body>
https://d3js.org/d3.v4.min.js