width and height in simulationOptions should default to '100%'
dbkaplun opened this issue · 2 comments
width and height in simulationOptions should should be allowed to be strings rather than only numbers and default to '100%'. Setting them to '100%' now causes errors but sets the attributes correctly, resulting in the desired effect.
d3-force does not support percentage-based widths, as far as we've been able to tell. you can get this behavior by wrapping your component with resizing wrapper, which you could use a higher order component such as https://github.com/digidem/react-dimensions to accomplish. We should probably add this to our docs so I'm going to leave this issue open until we do so.
That makes sense, but I think that if you don't set the width
& height
attributes on the <svg>
then the resulting graph would be responsive - which would be a better default than the current hardcoded values. It should be cleaner than measuring the container size and then passing that down if this works.
See this SO answer for more info: https://stackoverflow.com/a/11948988/1262824