(function() { window.main = function() { var colorify, height, path_generator, svg, thicken, width; width = 960; height = 500; svg = d3.select('body').append('svg').attr('width', width).attr('height', height); /* translate and scale projection with flipped y axis */ path_generator = d3.geo.path().projection(d3.geo.transform({ point: function(x, y) { return this.stream.point(10 + 10 * x, 10 - 10 * y); } })); /* define a color scale for property a */ colorify = d3.scale.category10().domain(['x', 'y', 'z']); /* define a width scale for property b */ thicken = d3.scale.linear().domain([1, 10]).range([1, 10]); /* load topoJSON data */ return d3.json('data.topo.json', function(error, data) { /* draw the result */ return svg.selectAll('.region').data(topojson.feature(data, data.objects.data).features).enter().append('path').attr('class', 'region').attr('d', path_generator).attr('fill', function(d) { return colorify(d.properties.a); }).attr('stroke-width', function(d) { return thicken(d.properties.b); }).attr('transform', 'translate(280,120)'); }); }; }).call(this);