D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
arjunsudhir
Full window
Github gist
Hello universe
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> <svg> <circle cx="20" cy="20" r="10" fill="red"> </svg> <script> // Feel free to change or delete any of the code you see in this editor! var data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] var data_points = data.map(x=>[x+50,x*x]) console.log(data_points[0]) var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500) svg.append("text") .text("Hello universe!") .attr("y", 200) .attr("x", 120) .attr("font-size", 28) .attr("font-family", "monospace") svg.selectAll("rect") .data(data_points) .enter() .append("rect") .attr("class","green-circle") .attr("width", 50) .attr("height", 10) .attr("x", d=>d[0]) .attr("y", d=>d[1]) .attr("fill","steelblue") .attr("stroke","black") </script> <p>Something goes here</p> </body>
https://d3js.org/d3.v4.min.js