This file shows how to use the geoConicConformalFrance projection from d3-composite-projections. without using node.
Last active
September 25, 2016 21:39
-
-
Save rveciana/bf9ff81544da5fe8ee54a2ba4ef45e9c to your computer and use it in GitHub Desktop.
conicConformalFrance linked directly example
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> | |
.states { | |
fill: #ccc; | |
stroke: #fff; | |
} | |
</style> | |
<body> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-composite-projections/1.0.1/d3-composite-projections.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var projection = d3.geoConicConformalFrance(); | |
var path = d3.geoPath() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var t = d3.transition(); | |
d3.json("france.json", function(error, france) { | |
var france = topojson.feature(france, france.objects.regions); | |
svg.selectAll(".region") | |
.data(france.features) | |
.enter() | |
.append("path") | |
.attr("class", "region") | |
.attr("d", path) | |
.style("fill", "#aca") | |
.style("stroke", "#000") | |
.style("stroke-width", "0.5px") | |
.on("mouseover", function(d,i) { | |
d3.select(this).interrupt(); | |
d3.select(this) | |
.transition(t) | |
.style("fill", "red"); | |
}) | |
.on("mouseout", function(d,i) { | |
d3.select(this).interrupt(); | |
d3.select(this) | |
.transition(t) | |
.style("fill", "#aca"); | |
});; | |
svg | |
.append("path") | |
.style("fill","none") | |
.style("stroke","#f00") | |
.attr("d", projection.getCompositionBorders()); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment