This example shows how to use the conicConformalEurope projection from d3-composite-projections.
Last active
February 3, 2017 20:45
-
-
Save rveciana/4bcc5750c776c22ffda6 to your computer and use it in GitHub Desktop.
d3-composite-projections conicConformalEurope
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> | |
.land { | |
fill: #222; | |
} | |
.county-boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
.state-boundary { | |
fill: none; | |
stroke: #fff; | |
} | |
.border { | |
stroke: #000; | |
fill: none; | |
} | |
.graticule { | |
fill: none; | |
stroke: #777; | |
stroke-width: .5px; | |
stroke-opacity: .5; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-composite-projections/0.3.5/conicConformalEurope-proj.min.js"></script> | |
<script> | |
var width = 600, | |
height = 500; | |
var projection = d3.geo.conicConformalEurope(); | |
var graticule = d3.geo.graticule(); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path); | |
d3.json("https://cdn.rawgit.com/rveciana/5919944/raw//nuts0.json", function(error, europe) { | |
var land = topojson.feature(europe, europe.objects.nuts0); | |
svg.selectAll("path") | |
.data(land.features) | |
.enter() | |
.append("path") | |
.attr("d", path) | |
.style("stroke","#000") | |
.style("stroke-width",".5px") | |
.style("fill","#aca") | |
.on("mouseover", function(d,i) { | |
d3.select(this) | |
.transition() | |
.style("fill", "red"); | |
}) | |
.on("mouseout", function(d,i) { | |
d3.select(this) | |
.transition() | |
.style("fill", "#aca"); | |
}); | |
svg | |
.append("path") | |
.style("fill","none") | |
.style("stroke","#000") | |
.attr("d", projection.getCompositionBorders()); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment