D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
imjcl
Full window
Github gist
A horizontal bar chart showing 2010-2012 median incomes for over 173 college majors in the United States, in USD.
<!DOCTYPE html> <html> <head> <title>College Majors - Module 3</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> </head> <body> <h1>College Majors Median Income</h1> <p>This horizontal bar chart shows the median incomes for 173 different college majors.</p> <script> var svg = d3.select("body") .append("svg") .attr("width", 1200) .attr("height", 1800) d3.csv("college-majors-employment-data.csv", function(data) { data.sort(function(a, b) { return a.Median - b.Median; }).reverse(); 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.Median / 100; }) .attr("height", 8) .append('title') .text(function(d) { return d.Major + "'s median income is: " + d.Median; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js