Skip to content

Instantly share code, notes, and snippets.

@jeremycflin
Created December 20, 2017 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremycflin/a1d3ee64f744134b2064b01e57535007 to your computer and use it in GitHub Desktop.
Save jeremycflin/a1d3ee64f744134b2064b01e57535007 to your computer and use it in GitHub Desktop.
County Circles
license: gpl-3.0

This symbol map encodes the area of each county using a circle at the county's centroid.

forked from mbostock's block: County Circles

<!DOCTYPE html>
<meta charset="utf-8">
<style>
circle {
fill: none;
stroke: steelblue;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("https://gist.githubusercontent.com/mbostock/4090846/raw/d534aba169207548a8a3d670c9c2cc719ff05c47/us.json", function(error, us) {
if (error) throw error;
svg.selectAll("circle")
.data(topojson.feature(us, us.objects.counties).features)
.enter().append("circle")
.attr("transform", function(d) { return "translate(" + path.centroid(d) + ")"; })
.attr("r", function(d) { return Math.sqrt(path.area(d) / Math.PI); });
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment