Built with blockbuilder.org
Last active
January 7, 2019 15:10
-
-
Save christopherGizard/2acc893cb9bef669a8123fb5202ed189 to your computer and use it in GitHub Desktop.
fresh block
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
license: mit |
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> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
.land { | |
fill: #ddd; | |
} | |
.border { | |
fill: none; | |
stroke: #fff; | |
stroke-linejoin: round; | |
stroke-linecap: round; | |
} | |
.bubble { | |
fill: brown; | |
fill-opacity: .5; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
.bubble :hover { | |
stroke: #000; | |
} | |
.legend circle { | |
fill: none; | |
stroke: #ccc; | |
} | |
.legend text { | |
fill: #777; | |
font: 10px sans-serif; | |
text-anchor: middle; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
// Feel free to change or delete any of the code you see in this editor! | |
var width = 960, | |
height = 600; | |
var formatNumber = d3.format(",.0f"); | |
var projection = d3.geoMercator() | |
.center([110, 12]) | |
.scale([600]) | |
.translate([550,550]) | |
.precision([.1]); | |
var path = d3.geoPath() | |
.projection(projection); | |
var radius = d3.scaleSqrt() | |
.domain([0, 1e6]) | |
.range([0, 15]); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var legend = svg.append("g") | |
.attr("class", "legend") | |
.attr("transform", "translate(" + (width - 50) + "," + (height - 20) + ")") | |
.selectAll("g") | |
.data([1e6, 5e6, 1e7]) | |
.enter().append("g"); | |
legend.append("circle") | |
.attr("cy", function(d) { return -radius(d); }) | |
.attr("r", radius); | |
legend.append("text") | |
.attr("y", function(d) { return -2 * radius(d); }) | |
.attr("dy", "1.3em") | |
.text(d3.format(".1s")); | |
d3.json("china.geojson", function(error, us) { | |
if (error) throw error; | |
svg.append("path") | |
.datum(topojson.feature(us)) | |
.attr("class", "land") | |
.attr("d", path); | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment