D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
EgorBrus
Full window
Github gist
Belarus population by region
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Belarus population by region</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: white; font-family: segoe ui light; font-size: 10px; color: lightslategray;} svg { background-color: white;} rect { fill: lightslategray;} rect:hover { opacity: 0.6;} </style> </head> <body> <h1>Belarus population by region</h1> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 300) .attr("height", 220); d3.csv("Belarus-population-xlsx.csv", function(data) { data.sort(function(a, b) {return d3.descending(a.population, b.population);}); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 140) .attr("y", function(d, i) {return i * 30;}) .attr("width", function(d) {return d.population * 0.1;}) .attr("height", 25) .append("title") .text(function(d) {return d.region + "'s population is " + d.population;}); svg.selectAll("text") .data(data) .enter() .append("text") .text(function(d){return d.region;}) .attr("x", 135) .attr("y", function(d, i){return i * 30 + 17;}) .attr({"fill": "black", "font-size": "14px", "text-anchor": "end"})}); </script> <p></p><em><b>Source:</b> National statistics committee of the Republic of Belarus (<url>https://belstat.gov.by/ssrd-mvf/ssrd-mvf_2/natsionalnaya-stranitsa-svodnyh-dannyh/chislennost-naseleniya-na-1-yanvarya-po-oblastyam-respubliki-belarus/</url>)</em></p> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js