D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
CatLeal
Full window
Github gist
Infant Mortality Rate EU 2012 W3
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>HeroScore Top100 | Week 3</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> </head> <body> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 800) .attr("height", 1500); //Load in contents of CSV file d3.csv("Data_InfantMortalityRate.csv", function(data) { data.sort(function(a, b) { return d3.ascending(a.a2012, b.a2012); }); 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) { return d.a2012 * 30; }) .attr("height", 8) .append("title") .text(function(d) { return d.Country + "'s Infant Mortality Rate in 2012 was " + d.a2012; }); //Now CSV contents have been transformed into //an array of JSON objects. //Log 'data' to the console, for verification. console.log(data); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js