D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
daryadm
Full window
Github gist
Russian "SAT" test participants
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Creating HTML Elements from 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: gray; } h1 { font-family: Arial; font-size: 12; color: black; } h3 { font-family: Arial; font-size: 9; color: black; } </style> </head> <body> <h1>Russian "SAT" subject test participants</h1> <h3> Number of participants</h3> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 820) .attr("height", 860); d3.csv("EGE2013_count students.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.All_Participants_Count, +b.All_Participants_Count); //'+' is needed for converting data to string }) svg.selectAll("rect") .data(data) .enter() .append("rect") .attr("x", 0) .attr("y",function(d,i) { return i*10; }) .attr("width",function(d) { return d.All_Participants_Count * 0.01; }) .attr("height",8) .attr("fill", "yellow") .attr("stroke", "red") .append("title") .text(function(d) { return d.Reg_name + "'s number of all participants'13 is " + d.All_Participants_Count; }); /*svg.selectAll("line") .data(data) .enter() .append("line"); .attr("x1", 0) .attr("y1", function(d, i) { return i*10; }) .attr("x2", 0) .attr("x2", function(d) { return d.Senior_count * 0.01; }) .attr("y2", function(d, i) { return i * 12+5; }) .attr("stroke", "#F05A28") .attr("stroke-width", "2");*/ }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js