Last active
January 1, 2016 04:09
-
-
Save bradllj/8090200 to your computer and use it in GitHub Desktop.
World Document Count
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.subunit { fill: #aaa; } | |
.q0-9 { fill:rgb(247,251,255); } | |
.q1-9 { fill:rgb(222,235,247); } | |
.q2-9 { fill:rgb(198,219,239); } | |
.q3-9 { fill:rgb(158,202,225); } | |
.q4-9 { fill:rgb(107,174,214); } | |
.q5-9 { fill:rgb(66,146,198); } | |
.q6-9 { fill:rgb(33,113,181); } | |
.q7-9 { fill:rgb(8,81,156); } | |
.q8-9 { fill:rgb(8,48,107); } | |
.subunit-boundary { | |
fill: none; | |
stroke: #777; | |
stroke-linejoin: round; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="http://d3js.org/queue.v1.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var projection = d3.geo.mercator() | |
.scale(100) | |
.translate([width / 2, height / 2]); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var test = 0; | |
var countByName = d3.map(); | |
queue() | |
.defer(d3.json, "/bradllj/raw/8250227/world.json") | |
.defer(d3.json, "/bradllj/raw/8250265/toplocations.json") | |
.await(ready); | |
var quantize = d3.scale.quantize() | |
.domain([0, 2000]) | |
.range(d3.range(9).map(function(i) { return "q" + i + "-9"; })); | |
function ready(error, world, locations) { | |
locations.forEach(function(data) { | |
//console.log(data.value.toLowerCase()) | |
//console.log(data.value + " " +quantize(data.count)); | |
countByName.set(data.value, data.count); | |
}) | |
svg.selectAll(".subunit") | |
.data(topojson.feature(world, world.objects.countries).features) | |
.enter().append("path") | |
.attr("class", function(d) { return "subunit " + quantize(countByName.get(d.id.toLowerCase())); }) | |
.attr("d", path); | |
/*.attr("class", function(d) { return "subunit " + d.id; }) */ | |
svg.append("path") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b })) | |
.attr("d", path) | |
.attr("class", "subunit-boundary"); | |
svg.append("path") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a == b })) | |
.attr("d", path) | |
.attr("class", "subunit-boundary"); | |
}; | |
</script> |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment