Skip to content

Instantly share code, notes, and snippets.

@NPashaP
Last active October 25, 2018 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NPashaP/ed2b1cb3bca196cd86e03437df5e7238 to your computer and use it in GitHub Desktop.
Save NPashaP/ed2b1cb3bca196cd86e03437df5e7238 to your computer and use it in GitHub Desktop.
US County Map - Basic
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body{
font-family:Roboto;
font-size: .6rem;
}
.state-border {
fill: none;
stroke: #000;
stroke-width: .5px;
}
.counties {
fill: #eee;
stroke: #bbb;
stroke-width: .5px;
}
.counties path:hover {
fill: #ddd;
}
.county-border{
fill: none;
stroke:#fff;
stroke-width:2px;
}
.county-name text{
text-anchor: middle;
pointer-events:none;
}
</style>
<body>
<svg></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="http://vizjs.org/viz.v1.2.0.min.js"></script>
<script>
var width=960, height=1800;
d3.json(viz.maps.uscountyurl, function(error, uscjson) {
if (error) throw error;
viz.maps.uscounties=uscjson;
var counties = viz.uscs()
.state('NJ')
.height(height)
.width(width);
d3.select("svg")
.attr("width",width)
.attr("height",height)
.call(counties);
});
// adjust the bl.ocks frame dimension.
d3.select(self.frameElement).style("height",height+"px").style("width",width+"px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment