Skip to content

Instantly share code, notes, and snippets.

@tpreusse
tpreusse / fitProjection.js
Last active July 21, 2016 12:09 — forked from nrabinowitz/fitProjection.js
D3 function for fitting a projection to geodata
import d3 from 'd3';
export const fitProjection = (projection, data, box, center) => {
// get the bounding box for the data - might be more efficient approaches
let left = Infinity;
let bottom = -Infinity;
let right = -Infinity;
let top = Infinity;
// reset projection
projection.scale(1).translate([0, 0]);