D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
nydame
Full window
Github gist
Exercise 2 for Data Visualization and Infographics with D3
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Loading CSV Data with D3</title> <style type="text/css"> body { background-color: whitesmoke; } svg { background-color: mistyrose } </style> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> </head> <body> <svg width="600" height="400"> <line x1="10" y1="10" x2="10" y2="390" stroke="gray" stroke-width="3" /> <line x1="50" y1="200" x2="590" y2="200" stroke="gray" stroke-width="3" /> <rect x="200" y="10" width="100" height="100" fill="orange" /> <circle cx="300" cy="120" r="60" fill="violet" /> <circle cx="410" cy="60" r="40" fill="charcoal" /> <circle cx="500" cy="350" r="40" fill="rebeccapurple" /> <polygon points="550,300 525,350 575,350" fill="goldenrod" /> <text x="208" y="100" fill="#ffffff" font-size="42" font-weight="bold" font-family="Impact">Nothing to see here…</text> <text x="20" y="300" fill="#ffffff" font-size="42" font-weight="bold" font-family="Impact">check the console!</text> </svg> <script type="text/javascript"> //Load in contents of CSV file d3.csv("CA-diabetes-data.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