forked from scotthmurray/d3-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added geodata and first example, cited geodata in README
- Loading branch information
Scott Murray
committed
Nov 13, 2012
1 parent
e4cf85e
commit 19abd87
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>D3 Demo: GeoJSON</title> | ||
<script type="text/javascript" src="../d3/d3.v2.js"></script> | ||
<style type="text/css"> | ||
/* No style rules here yet */ | ||
</style> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
//Width and height | ||
var w = 500; | ||
var h = 300; | ||
|
||
//Create SVG element | ||
var svg = d3.select("body") | ||
.append("svg") | ||
.attr("width", w) | ||
.attr("height", h); | ||
|
||
//Load in GeoJSON data | ||
d3.json("us-states.json", function(json) { | ||
|
||
//Define default path generator | ||
var path = d3.geo.path(); | ||
|
||
//Bind data and create one path per GeoJSON feature | ||
svg.selectAll("path") | ||
.data(json.features) | ||
.enter() | ||
.append("path") | ||
.attr("d", path); | ||
|
||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.