Skip to content

Instantly share code, notes, and snippets.

Forked from mbostock/.block
Last active March 26, 2023 23:55
What would you like to do?
Symbol Map
license: gpl-3.0

The area of each circle in this symbol map is proportional to the population of the associated state.

<!DOCTYPE html>
<meta charset="utf-8">
.states {
fill: #ccc;
stroke: #fff;
.symbol {
fill: steelblue;
fill-opacity: .8;
stroke: #fff;
<script src="//"></script>
<script src="//"></script>
<script src="//"></script>
var width = 960,
height = 500;
var radius = d3.scale.sqrt()
.domain([0, 1e6])
.range([0, 10]);
var path = d3.geo.path();
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
.defer(d3.json, "/mbostock/raw/4090846/us.json")
.defer(d3.json, "us-state-centroids.json")
function ready(error, us, centroid) {
if (error) throw error;
.attr("class", "states")
.datum(topojson.feature(us, us.objects.states))
.attr("d", path);
.data(centroid.features.sort(function(a, b) { return -; }))
.attr("class", "symbol")
.attr("d", path.pointRadius(function(d) { return radius(; }));
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment