Skip to content

Instantly share code, notes, and snippets.

@cornfact
Last active September 8, 2015 17:01
Show Gist options
  • Save cornfact/6c16aa93cc1e8ca9d2d5 to your computer and use it in GitHub Desktop.
Save cornfact/6c16aa93cc1e8ca9d2d5 to your computer and use it in GitHub Desktop.
USDA Layers & Eggs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loading CSV Data with D3</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
</style>
</head>
<body>
<svg width="500" height="200">
<line x1="10" y1="10" x2="500" y2="10" stroke="black" stroke-width="1" />
<line x1="10" y1="55" x2="500" y2="55" stroke="black" stroke-width="1" />
<text x="10" y="40" fill="charcoal" font-size="20" font-family="Helvetica">USDA Layers & Eggs</text>
</svg>
<script type="text/javascript">
//Load in contents of CSV file
d3.csv("usdalayersandeggs.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>
Month 2014 layers 2015 layers 2014 eggs 2015 eggs
Dec 360.7 365.7 8.5 8.7
Jan 359.6 363.7 8.4 8.5
Feb 359.0 362.3 7.6 7.6
Mar 360.0 362.5 8.4 8.5
Apr 360.8 358.4 8.2 8.2
May 359.7 341.6 8.4 8.0
Jun 360.8 328.7 8.2 7.4
Jul 360.8 328.7 8.5 7.7
Aug 361.7 0.0 8.5 0.0
Sep 361.8 0.0 8.2 0.0
Oct 362.0 0.0 8.5 0.0
Nov 364.0 0.0 8.4 0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment