D3 2.10 adds support for threshold scales which make it easy to apply arbitrary quantization.
-
-
Save mango314/4503529 to your computer and use it in GitHub Desktop.
This file contains hidden or 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"> | |
<body> | |
<script src="https://raw.github.com/mbostock/d3/2.10.0/d3.v2.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var color = d3.scale.threshold() | |
.domain([2, 4, 6, 8, 10]) | |
.range(["#f2f0f7", "#dadaeb", "#bcbddc", "#9e9ac8", "#756bb1", "#54278f"]); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("unemployment.json", function(data) { | |
d3.json("readme.json", function(collection) { | |
svg.selectAll("path") | |
.data(collection.features) | |
.enter().append("path") | |
.attr("d", path) | |
.attr("class", function(d) { return color(data[d.id]); }); | |
}); | |
}); | |
</script> |
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