Built with blockbuilder.org
Created
June 9, 2020 10:39
-
-
Save GerardoFurtado/5dcf02732bf2f4cf5f76b983330ac240 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"> | |
<script src="https://d3js.org/d3.v5.min.js"></script> | |
<script src="https://unpkg.com/topojson@3"></script> | |
</head> | |
<body> | |
<script> | |
const width = 600, | |
height = 400, | |
colours = d3.scaleOrdinal(d3.schemeCategory10), | |
mapProjection = d3.geoMercator(), | |
mapPath = d3.geoPath().projection(mapProjection); | |
const svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("data.json").then(function(data) { | |
const features = topojson.feature(data, data.objects.sql); | |
mapProjection.fitSize([width, height], features); | |
const clusters = svg.selectAll(null) | |
.data(features.features) | |
.enter() | |
.append("path") | |
.attr("d", mapPath) | |
.style("fill", function(_, i) { | |
return colours(i) | |
}); | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment