Skip to content

Instantly share code, notes, and snippets.

@bsullins
Last active April 12, 2016 17:12
Show Gist options
  • Save bsullins/7f2be1f22b7244901a62ddadf2460a41 to your computer and use it in GitHub Desktop.
Save bsullins/7f2be1f22b7244901a62ddadf2460a41 to your computer and use it in GitHub Desktop.
first-blocks
license: gpl-3.0

Hello Blocks!

this is my first gist to block

<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="light.css">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 600;
var path = d3.geo.path()
.projection(null);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("us.json", function(error, us) {
if (error) throw error;
svg.append("path")
.datum(topojson.feature(us, us.objects.nation))
.attr("class", "land")
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(us, us.objects.states, function(a,b) { return a !==b; }))
.attr("class", "border border--state")
.attr("d", path);
svg.append("g")
.attr("class", "bubble")
.selectAll("circle")
.data(topojson.feature(us, us.objects.counties).features)
.enter().append("circle")
//find the centroid of the county and put the dot there
.attr("transform", function(d) { return "translate(" + path.centroid(d) + ")"; })
//choose the radius size
.attr("r", function(d) { return Math.sqrt(parseFloat(d.properties.profit)* 0.00005) });
});
</script>
/mbostock/raw/4090846/us.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment