D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
toskolina
Full window
Github gist
Lobbying
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Lobbying costs</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: white; } svg { background-color: pink; } </style> </head> <body> <h1> Top 24 lobbying organisations </h1> <script type="text/javascript"> //Width and height var w = 1000; var h = 300; var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); d3.csv("LobbyingCost.csv", function(data) { data.sort(function(a, b) { return d3.descending(a.LobbyingCosts, b.LobbyingCosts); }); var rects = svg.selectAll("rect") .data(data) .enter() .append("rect"); rects.attr("x", 0) // return i * (w/dataset.length) .attr("y", function(d, i) { return i * 10; }) .attr("width", function(d) { return d.LobbyingCosts / 10000; }) .attr("height", 8) .attr("fill", "teal") .append("title") .text(function(d) { return d.OrganisationName + " operates in " + d.CountryOfContact + " and spent " + d.LobbyingCosts + " euros in lobbying"; }); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js