D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
rasou2ba
Full window
Github gist
corrected Q13 - should add svg before .append("rect")
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> var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 960) //Select the svg and put some rectangles in it d3.select("svg").selectAll("rect") //DON'T ACTUALLY NEED THIS LINE svg.append("rect") //modify the rectangles. .attr("y", 50) .attr("x", 50) .attr("width", 67.5) //this is the same for every rectangle .attr("height", 15) .attr("fill","#0055A4") svg.append("rect") .attr("y",65) .attr("x", 50) .attr("width", 67.5) //this is the same for every rectangle .attr("height", 15) .attr("fill","#FFFFFF") svg.append("rect") .attr("y",80) .attr("x", 50) .attr("width", 67.5) //this is the same for every recangle .attr("height", 15) .attr("fill","#EF4135") </script> </body>
https://d3js.org/d3.v4.min.js