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

[question] Default tree is not centered and nodes are cut off #476

Open
mgroma opened this issue Oct 1, 2023 · 1 comment
Open

[question] Default tree is not centered and nodes are cut off #476

mgroma opened this issue Oct 1, 2023 · 1 comment

Comments

@mgroma
Copy link

mgroma commented Oct 1, 2023

I used the default example from the "Usage" section. Is it expected that the root node shows up in the top left corner and other nodes are cut off - see the image? I'm using the latest version.
image

If so, is there an option to center the root node and automatically zoom out to fit all nodes?

@cabbagetom
Copy link

@mgroma. To answer the first part of your question, there is a TreeProp called translate which translates the graph along the x/y axis by the specified amount of pixels. If you set up some code like the following, you can then set the prop value to treeContainerDimensions.width and .height/2 to ensure that it is always centred in all viewports.
const dimensions = treeContainer.getBoundingClientRect(); setTreeContainerDimensions({ width: dimensions.width, height: dimensions.height, });
Regarding the second part on zooming out, sorry don't know enough about what is going on under the hood to answer this

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

2 participants