D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
micahstubbs
Full window
Github gist
Materials in Houston Public Art
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Materials in Houston Public Art</title> <script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> <style type="text/css"> body { background-color: #FFFFFF; } svg { background-color: white; } </style> </head> <body> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 300) .attr("height", 400); d3.csv("houston-public-art.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.countOfMaterials, +b.countOfMaterials); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) .attr("y", function(d, i){ return i * 10; }) .attr("width", function(d, i){ return d.countOfMaterials * 75; // where 75 is an arbitrary scaling factor calculated to match the maximum value of the dataset field - 4 - to the width of the svg - 300px }) .attr("height", 8) .style("fill", "steelblue") .append("title") .text(function(d){ return d.displayTitle + " by " + d.displayArtist + " - " + d.mediaAndSupport; }) }); </script> </body> </html>
https://d3js.org/d3.v3.min.js