D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
savinip
Full window
Github gist
2014_2011 threatened Italian journalists, per Region
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>exercise 3 paola</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: #ed2150; } svg { background-color: white; } </style> </head> <body> <body> <h1> N. of threatened Italian journalists between 2011 and 2014, per Region</h1> Source: <a href="https://notiziario.ossigeno.info/"> Ossigeno per l'informazione <br> <script type="text/javascript"> var svg = d3.select("body") .append("svg") .attr("width", 600) .attr("height", 300); d3.csv("index.csv", function(data) { data.sort(function(a, b) { return d3.descending(+a.threatenedjournalists20112014, +b.threatenedjournalists20112014); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) .attr("y", function(d, i) { return (i * 20) + 20; }) .attr("fill","#2758c7") .attr("width", function(d) { return d.threatenedjournalists20112014 * 2; }) .attr("height", 10) .append("title") .text(function(d) { return d.Italianregions + "'s threatened journalists between 2011 and 2014 were " + d.threatenedjournalists20112014; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js