{"action":"closed","issue":{"url":"https://api.github.com/repos/twitter/d3kit/issues/14","repository_url":"https://api.github.com/repos/twitter/d3kit","labels_url":"https://api.github.com/repos/twitter/d3kit/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/twitter/d3kit/issues/14/comments","events_url":"https://api.github.com/repos/twitter/d3kit/issues/14/events","html_url":"https://github.com/twitter/d3kit/issues/14","id":148400014,"number":14,"title":"Auto-resizing only working in one direction","user":{"login":"Brideau","id":844397,"avatar_url":"https://avatars.githubusercontent.com/u/844397?v=3","gravatar_id":"","url":"https://api.github.com/users/Brideau","html_url":"https://github.com/Brideau","followers_url":"https://api.github.com/users/Brideau/followers","following_url":"https://api.github.com/users/Brideau/following{/other_user}","gists_url":"https://api.github.com/users/Brideau/gists{/gist_id}","starred_url":"https://api.github.com/users/Brideau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brideau/subscriptions","organizations_url":"https://api.github.com/users/Brideau/orgs","repos_url":"https://api.github.com/users/Brideau/repos","events_url":"https://api.github.com/users/Brideau/events{/privacy}","received_events_url":"https://api.github.com/users/Brideau/received_events","type":"User","site_admin":false},"labels":[{"id":164891368,"url":"https://api.github.com/repos/twitter/d3kit/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":{"login":"kristw","id":1659771,"avatar_url":"https://avatars.githubusercontent.com/u/1659771?v=3","gravatar_id":"","url":"https://api.github.com/users/kristw","html_url":"https://github.com/kristw","followers_url":"https://api.github.com/users/kristw/followers","following_url":"https://api.github.com/users/kristw/following{/other_user}","gists_url":"https://api.github.com/users/kristw/gists{/gist_id}","starred_url":"https://api.github.com/users/kristw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristw/subscriptions","organizations_url":"https://api.github.com/users/kristw/orgs","repos_url":"https://api.github.com/users/kristw/repos","events_url":"https://api.github.com/users/kristw/events{/privacy}","received_events_url":"https://api.github.com/users/kristw/received_events","type":"User","site_admin":false},"assignees":[{"login":"kristw","id":1659771,"avatar_url":"https://avatars.githubusercontent.com/u/1659771?v=3","gravatar_id":"","url":"https://api.github.com/users/kristw","html_url":"https://github.com/kristw","followers_url":"https://api.github.com/users/kristw/followers","following_url":"https://api.github.com/users/kristw/following{/other_user}","gists_url":"https://api.github.com/users/kristw/gists{/gist_id}","starred_url":"https://api.github.com/users/kristw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristw/subscriptions","organizations_url":"https://api.github.com/users/kristw/orgs","repos_url":"https://api.github.com/users/kristw/repos","events_url":"https://api.github.com/users/kristw/events{/privacy}","received_events_url":"https://api.github.com/users/kristw/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-04-14T15:33:25Z","updated_at":"2016-11-08T19:57:32Z","closed_at":"2016-11-08T19:57:32Z","body":"I'm working with a chart using `autoResize` to `true` and `autoResizeToAspectRatio` set to 1.5. I noticed that if I shrunk the browser window, the chart resized properly, but if I then made it large again, the chart stayed small.\n\nThe issue seems to come from `resizeToAspectRatio` function. For example, if you start with a large div and go to a small one, the div proportions go from:\n- _totalWidth = 700\n- _totalHeight = 467\n- estimatedHeight = 467\n\nTo:\n- _totalWidth = 400\n- _totalHeight = 467\n- estimatedHeight = 267\n\nThe if/else statement on [line 663](https://github.com/twitter/d3kit/blob/master/dist/d3kit.js#L663) then correctly says \"if the estimated height is not larger than the height, change the height to the estimated height.\"\n\nIn the opposite direction, however, it does this:\n- _totalWidth = 400\n- _totalHeight = 267\n- estimatedHeight = 267\n\nTo:\n- _totalWidth = 700\n- _totalHeight = 267\n- estimatedHeight = 467\n\nThe same if/else statement then effectively says \"if the estimated height is greater than the total height, adjust the width.\" But the width is already adjusted, so nothing updates.\n\nI patched this by changing:\n\n```\n  if (estimatedH > h) {\n    width(Math.floor(h * ratio), doNotDispatch);\n  } else {\n    height(estimatedH, doNotDispatch);\n  }\n```\n\nTo:\n\n```\n  if (estimatedH > h) {\n    height(estimatedH, doNotDispatch);\n    width(Math.floor(estimatedH * ratio), doNotDispatch);\n  } else {\n    height(estimatedH, doNotDispatch);\n  }\n```\n\nBut, I'm not sure if that works in all cases, so perhaps there's a cleaner solution.\n"}}
{"actor":{"display_login":"kristw"}}