D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
enricocosta
Full window
Github gist
CO2 Emissions Test
<!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> <style type="text/css"> body { background-color: #ffffbf; } svg { background-color: #abd9e9; } </style> </head> <body> <svg width="600" height="250"> <line x1="10" y1="240" x2="300" y2="240" stroke="#d7191c" stroke-width="0.5" /> <line x1="590" y1="10" x2="590" y2="240" stroke="#d7191c" stroke-width="0.5" /> <rect x="450" y="80" width="120" height="120" fill="#fdae61" /> <circle cx="100" cy="235" r="10" fill="#dadaeb" /> <circle cx="130" cy="220" r="15" fill="#bcbddc" /> <circle cx="155" cy="180" r="23" fill="#9e9ac8" /> <circle cx="198" cy="100" r="50" fill="#4a1486" /> <circle cx="200" cy="155" r="30" fill="#6a51a3" /> <text x="20" y="20" fill="charcoal" font-size="16" font-weight="regular" font-family="Helvetica">CO2 Emissions in Italy 1990-2010</text> </svg> <script type="text/javascript"> //Load in contents of CSV file d3.csv("ISPRA_CO2_PROV_1990.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>
Updated missing url
HTTP://d3js.org/d3.v3.js
to
http://d3js.org/d3.v3.js