{"action":"created","issue":{"url":"https://api.github.com/repos/gka/d3-jetpack/issues/49","repository_url":"https://api.github.com/repos/gka/d3-jetpack","labels_url":"https://api.github.com/repos/gka/d3-jetpack/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/gka/d3-jetpack/issues/49/comments","events_url":"https://api.github.com/repos/gka/d3-jetpack/issues/49/events","html_url":"https://github.com/gka/d3-jetpack/issues/49","id":261389883,"number":49,"title":"Switching to selectAppend in conventions?","user":{"login":"nstrayer","id":6764693,"avatar_url":"https://avatars3.githubusercontent.com/u/6764693?v=4","gravatar_id":"","url":"https://api.github.com/users/nstrayer","html_url":"https://github.com/nstrayer","followers_url":"https://api.github.com/users/nstrayer/followers","following_url":"https://api.github.com/users/nstrayer/following{/other_user}","gists_url":"https://api.github.com/users/nstrayer/gists{/gist_id}","starred_url":"https://api.github.com/users/nstrayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nstrayer/subscriptions","organizations_url":"https://api.github.com/users/nstrayer/orgs","repos_url":"https://api.github.com/users/nstrayer/repos","events_url":"https://api.github.com/users/nstrayer/events{/privacy}","received_events_url":"https://api.github.com/users/nstrayer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-28T16:54:31Z","updated_at":"2017-09-28T17:13:06Z","closed_at":null,"author_association":"NONE","body":"I find myself wanting to encapsulate my entire viz into a single function which is made massively easier by `selectAppend` (thank you so much for saving me from writing my own ugly version another time) but have found the process of resetting the svg/scales to be awkward with conventions. Would there be interest in replacing the [`append('svg')`](https://github.com/gka/d3-jetpack/blob/master/src/conventions.js#L38) with a `selectAppend` to allow for easy resizing? \r\nI may be incorrect in my decision to put the SVG setup into the big draw. It seems like the best way to do it currently is something along the lines of \r\n```js\r\nonResize = () => {\r\n  const newWidth = getNewWidth();\r\n  const newHeight = getNewHeight();\r\n  c.svg.parent().at(...);\r\n  // update scale ranges and reset the main g-container\r\n  drawViz(c);\r\n}\r\n```\r\nWhich feels... not right. With `selectAppend` it seems it could be as easy as putting `const c_new = d3.convention(...)` inside `drawViz()`. \r\n\r\nThis is asked with the idea of, if desired, I can submit a PR but I wanted to see if it was in keeping with the ethos of d3-jetpack. "},"comment":{"url":"https://api.github.com/repos/gka/d3-jetpack/issues/comments/332902973","html_url":"https://github.com/gka/d3-jetpack/issues/49#issuecomment-332902973","issue_url":"https://api.github.com/repos/gka/d3-jetpack/issues/49","id":332902973,"user":{"login":"1wheel","id":1643998,"avatar_url":"https://avatars1.githubusercontent.com/u/1643998?v=4","gravatar_id":"","url":"https://api.github.com/users/1wheel","html_url":"https://github.com/1wheel","followers_url":"https://api.github.com/users/1wheel/followers","following_url":"https://api.github.com/users/1wheel/following{/other_user}","gists_url":"https://api.github.com/users/1wheel/gists{/gist_id}","starred_url":"https://api.github.com/users/1wheel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1wheel/subscriptions","organizations_url":"https://api.github.com/users/1wheel/orgs","repos_url":"https://api.github.com/users/1wheel/repos","events_url":"https://api.github.com/users/1wheel/events{/privacy}","received_events_url":"https://api.github.com/users/1wheel/received_events","type":"User","site_admin":false},"created_at":"2017-09-28T17:13:06Z","updated_at":"2017-09-28T17:13:06Z","author_association":"COLLABORATOR","body":"Typically I blow away the entire chart on resize:\r\n\r\n    function drawChart(){\r\n      var sel = d3.select('.g-speed-path').html('')\r\n      var c = d3.conventions({sel})\r\n\r\n      ...\r\n    }\r\n\r\n    drawChart()\r\n    d3.select(window).on('resize', _.debounce(drawChart, 100))\r\n\r\nAs long as the resizing is debounced, I don't think there's a huge benefit to mutating the existing DOM elements to the new size. Most users don't resize and when they do the code should only get called once or twice.  \r\n\r\nAlso: after adding `layers`, I'm not sure that the `selectAppend` implementation would be simple. Possible to add two SVGs now!  "}}
{"actor":{"display_login":"1wheel"}}