D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
Audree
Full window
Github gist
Species Maximum Longevity Data Binding (module 3)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Binding Data</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: white; } svg { background-color: white; } </style> </head> <body> <p>Maximum Longevity (years) </p> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 1000) .attr("height", 5000); d3.csv("anage-data-txt-clean.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.MaximumLongevity, +b.MaximumLongevity); }); svg.selectAll("rect") .data(data) .enter() .append("rect") .attr("x", 0) .attr("y", function(d, i) { return i * 5; }) .attr("width", function(d) { return d.MaximumLongevity * 3; }) .attr("height", 4) .append("title") .text(function(d) { return d.CommonName + "'s maximum longevity is " + d.MaximumLongevity; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js