Create a gist now

Instantly share code, notes, and snippets.

D3 Choropleth Map Ireland
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<style type="text/css">
svg {
background: #eee;
}
#chart {
width: 400px;
height: 600px;
}
#ireland {
fill: #008000;
opacity: .8;
stroke: #000000;
stroke-width: .7;
}
</style>
</head>
<body>
<!--<h1 id='calendar_view'>Calendar View</h1>-->
<div class='gallery' id='chart'> </div>
<script type="text/javascript">
var w = 600;
var h = 600;
var proj = d3.geo.mercator();
var path = d3.geo.path().projection(proj);
var t = proj.translate(); // the projection's default translation
var s = proj.scale() // the projection's default scale
var map = d3.select("#chart").append("svg:svg")
.attr("width", w)
.attr("height", h)
// .call(d3.behavior.zoom().on("zoom", redraw))
.call(initialize);
var ireland = map.append("svg:g")
.attr("id", "ireland");
d3.json("ireland.json", function (json) {
ireland.selectAll("path")
.data(json.features)
.enter().append("path")
.attr("d", path);
});
function initialize() {
proj.scale(1200);
//proj.translate([-1240, 720]);
}
</script>
</body>
</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment