Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default zoom level to fit inside element #7

Open
khanh703 opened this issue Oct 23, 2014 · 1 comment
Open

Default zoom level to fit inside element #7

khanh703 opened this issue Oct 23, 2014 · 1 comment

Comments

@khanh703
Copy link

Is there a way to set the default zoom on.rendered so that graph fits inside element?

@khanh703
Copy link
Author

So I'm able to get the desired zoom value that will allow for the entire graph to fit inside my container. While the default zoom works to scale the graph to fit, the graph remains off centered, running graph.center(0) to center on the root node does not always work as there are always a few nodes that expands past the majority of the clusters. I can play around with the translation values, but I have no idea how these values (-1018.40185546875,-295.5054626464844) translates to graph being placed in the center of my container. How are the translate values defined?

default_zoom = (element.node().getBBox().height > element.node().getBBox().width) ? element.attr("height") / ( element.node().getBBox().height) :  element.attr("width")  / ( element.node().getBBox().width);
graph.zoom(default_zoom);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant