or downloading the
composite-projections.js or
composite-projections.min.js files.
Using cdnjs
You can link the files from your web page to
cdnjs:
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-composite-projections/0.3.5/composite-projections.min.js"></script>
Using bower
The bower package will install the production files, without tests or building options:
bower install d3-composite-projections
Using NPM
To install the projections with npm so you can run the tests, use it with node, etc, just run:
npm install d3-composite-projections
npm install -g gulp
gulp
This will download all the dependencies, the test files, and build and run the tests.
Example
Code:
var width = 900,
height = 500;
var projection = d3.geo.conicConformalFrance();
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("france.json", function(error, regions) {
var land = topojson.feature(regions, regions.objects.regions);
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());
});