D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ssalcido
Full window
Github gist
Canada immigrant population by province
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Immigrant population in Canada</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: white; margin-top: 20px; margin-left: 20px; } svg { background-color: white; } </style> </head> <body> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 1200) .attr("height", 400); d3.csv("population-immigrant-status-and-period_2006_canada.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.ImmigrantPopulation, +b.ImmigrantPopulation); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) .attr("y", function(d, i) { return i * 18; }) .attr("width", function(d) { return d.ImmigrantPopulation * 0.0009; }) .attr("height", 12) .attr("fill", "#b6b6b6") .append("title") .text(function(d) { return d.GeographicName + "'s immigration population is " + d.ImmigrantPopulation; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js