D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jkeohan
Full window
Github gist
D3_Course_Mod1_SimpleShapes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Loading CSV Data with D3</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> </head> <body> <svg width="500" height="500"> <text x="10" y="50" fill="charcoal" font-size="30" font-weight="bold" font-family="Helvetica">Circles and Rectangles</text> <circle cx="50" cy="140" r="5" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="20"/> <circle cx="90" cy="120" r="10" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="10"/> <circle cx="90" cy="160" r="10" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="10"/> <circle cx="130" cy="100" r="15" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="5"/> <circle cx="130" cy="140" r="15" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="5"/> <circle cx="130" cy="180" r="15" fill="rgba(0,0,204,0.75)" stroke="rgba(153,0,0,0.25)" stroke-width="5"/> <rect x="160" y="85" width="25" height="100" fill="rgba(0,0,204,0.75)"/> <rect x="160" y="95" width="25" height="100" fill="rgba(153,0,0,0.25)"/> <rect x="200" y="85" width="25" height="75" fill="rgba(0,0,204,0.75)"/> <rect x="200" y="115" width="25" height="80" fill="rgba(153,0,0,0.25)"/> <rect x="240" y="85" width="25" height="55" fill="rgba(0,0,204,0.75)"/> <rect x="240" y="140" width="25" height="55" fill="rgba(153,0,0,0.25)"/> </svg> <script type="text/javascript"> Load in contents of CSV file d3.csv("renewable-energy-perc-of-total-energy-generation.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