{"action":"opened","issue":{"url":"https://api.github.com/repos/d3/d3-geo/issues/49","repository_url":"https://api.github.com/repos/d3/d3-geo","labels_url":"https://api.github.com/repos/d3/d3-geo/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/d3/d3-geo/issues/49/comments","events_url":"https://api.github.com/repos/d3/d3-geo/issues/49/events","html_url":"https://github.com/d3/d3-geo/issues/49","id":164957766,"number":49,"title":"Add .contain() method?","user":{"login":"veltman","id":2120446,"avatar_url":"https://avatars.githubusercontent.com/u/2120446?v=3","gravatar_id":"","url":"https://api.github.com/users/veltman","html_url":"https://github.com/veltman","followers_url":"https://api.github.com/users/veltman/followers","following_url":"https://api.github.com/users/veltman/following{/other_user}","gists_url":"https://api.github.com/users/veltman/gists{/gist_id}","starred_url":"https://api.github.com/users/veltman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/veltman/subscriptions","organizations_url":"https://api.github.com/users/veltman/orgs","repos_url":"https://api.github.com/users/veltman/repos","events_url":"https://api.github.com/users/veltman/events{/privacy}","received_events_url":"https://api.github.com/users/veltman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-11T22:53:31Z","updated_at":"2016-07-11T22:53:31Z","closed_at":null,"body":"Any interest in adding a `projection.contain()` method that projects to a bounding box a la http://bl.ocks.org/mbostock/4707858?\r\n\r\nI think it's a pretty common use case to start with a bounding box rather than a desired scale/translate, and the alternative is to fiddle with values until it looks nice.\r\n\r\nI took a crack at it, mostly seems to work except I need to figure out why it doesn't work for projections with clipExtents:\r\n\r\nhttps://github.com/veltman/d3-geo/blob/master/src/projection/index.js#L81-100\r\n\r\nIn terms of naming, I chose `contain` because that's the CSS `background-size` nomenclature, but it could also be something like `fitTo`.\r\n\r\nThis would break the getter/setter pattern a bit.  Alternatively, it could be a more consistent separate method like:\r\n\r\n```\r\n  var projection = ...;\r\n\r\n  var fitter = d3.geoFit()\r\n    .projection(projection)\r\n    .width(1280)\r\n    .height(720)\r\n    .scale(0.9);\r\n\r\n  // Change\r\n  fitter.scale(1);\r\n\r\n```\r\n\r\nAlthough that seems kind of verbose.  Any thoughts?"}}
{"actor":{"display_login":"veltman"}}