D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jalapic
Full window
Github gist
Stop and Frisk NYC 2014
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adding Tooltips</title> <h1>Stop and Frisk Totals by Race for NYC in 2014 </h1> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> h1{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 26px; font-style: bold; } body { background-color: #F9FFFF; } svg { background-color: #F9FFFF; } .myrect { fill: #191970; } .myrect:hover { fill: #af1e23; } </style> </head> <body> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 500) .attr("height", 200); d3.csv("stopfrisksum.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.total, +b.total); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("class", "myrect") .attr("x", 0) .attr("y", function(d, i) { return i * 20; }) .attr("width", function(d) { return d.total / 50; }) .attr("height", 15) .append("title") .text(function(d) { return d.race + " individuals were stopped and frisked " + d.total + " times in NYC in 2014"; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js