D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
pierandrea
Full window
Github gist
#Knight D3 - Exercise Module 3 - Creating a bar chart
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>#KnightD3 - Exercise Module 3: Making a horizontal bar chart</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: orange; font-family: tahoma, helvetica; color: white; padding: 20px; } svg { background-color: orange; } div { text-align: center; } h1 { text-align: center; } p { text-align: center; } p.italic { font-style: italic; font-size: 6; } </style> </head> <body> <h1>Facebook Government Report</h1> <p>Account data requests received by Facebook from governments around the world in 2013</P> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 800) .attr("height", 400); d3.csv("FacebookGovRep.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.year2013, +b.year2013); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) .attr("y", function(d, i) { return i * 10; }) .attr("width", function(d) { return d.year2013 / 10; }) .attr("height", 8) .append("title") .text(function(d) { return d.year2013 + " " + d.Country + "'s Government requests to Facebook"; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js