D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
threestory
Full window
Github gist
2013 U.S. Suicide Deaths for 15-24 year-olds
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>U.S. Suicide Deaths</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: #808080; } svg { background-color: white; } </style> </head> <body> <h2 style="color:#fff; font-family:'Arial'">U.S. Suicide Deaths by State for 15-24 year olds, 2013</h2> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 600) .attr("height", 650); d3.csv("suicides_2013_states_15-24_part.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.deaths, +b.deaths); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 20) .attr("y", function(d, i) { return i * 12 + 20; }) .attr("width", function(d) { return d.deaths * 1.2; }) .attr("height", 10) .attr("fill", "#5288BE") .append("title") .text(function(d) { return d.state + "'s number of suicide deaths for the " + d.age_groups + " age range in " + d.year + " is " + d.deaths; }); }); </script> <p style="font-family:'Arial'">Note: Insufficient data for Washington D.C., Rhode Island, and Vermont</p> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js