D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
anuratim
Full window
Github gist
Income per capita - by country
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Income Per Capita - by country</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: #FFF; font-family: HelveticaNeue; } svg { background-color: #FFF; } </style> </head> <body> <script type="text/javascript"> var w = 1000; var h = 400; var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); d3.csv("WHO_data.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.incomePerCapita, +b.incomePerCapita); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) .attr("y", function(d, i) { return i * (h / data.length + 1); }) .attr("width", function(d) { return d.incomePerCapita / 100; }) .attr("height", (h / data.length)) .append("title") .text(function(d) { return d.country + "'s income per capita is " + d.incomePerCapita; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js