D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
crgpaterson
Full window
Github gist
International inequality and a red car!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Loading CSV Data with D3</title> <style type="text/css"> body { background-color: #eeeeff; } svg { background-color: white; } </style> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> </head> <body> <svg width="600" height="300"> <line x1="0" y1="295" x2="600" y2="295" stroke="black" stroke-width="10" /> <line x1="40" y1="62" x2="550" y2="62" stroke="black" stroke-width="3" /> <rect x="30" y="150" width="100" height="80" fill="red" /> <polygon points="450,210 600,280 450,280" fill="red" /> <polygon points="150,210 250,160 270,160 270,210 420,210 420,280 150,280" fill="red" /> <circle cx="450" cy="240" r="50" fill="grey" stroke="black" stroke-width="12" /> <circle cx="150" cy="240" r="50" fill="grey" stroke="black" stroke-width="12" /> <text x="80" y="50" fill="charcoal" font-size="42" font-weight="bold" font-family="Helvetica">Not much to see here;</text> <text x="40" y="100" fill="charcoal" font-size="42" font-weight="bold" font-family="Helvetica">try looking in the console</text> </svg> <script type="text/javascript"> //Load in contents of CSV file d3.csv("international_inequality.csv", function(data) { //Now CSV contents have been transformed into //an array of JSON objects. //Log 'data' to the console, for verification. console.log(data); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js