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

How to set zoom level(initial,min , max)?? #20

Closed
shikharka opened this issue Jan 4, 2018 · 9 comments
Closed

How to set zoom level(initial,min , max)?? #20

shikharka opened this issue Jan 4, 2018 · 9 comments
Assignees

Comments

@shikharka
Copy link

No description provided.

@vasturiano vasturiano self-assigned this Jan 4, 2018
@vasturiano
Copy link
Owner

vasturiano commented Jan 5, 2018

@shikharka the initial zoom level is calculated based on the number of nodes in the system, in a cubic relationship.
For reference, this is where that logic is applied:
https://github.com/vasturiano/3d-force-graph/blob/master/src/3d-force-graph.js#L132

There is no way currently to specify zoom max/min boundaries programmatically from outside the component.

@shikharka
Copy link
Author

shikharka commented Jan 10, 2018

It will be a good to have feature
I found 'e.camera.position.z=150*Math.cbrt(e.forceGraph.graphData().nodes.length) ' in the js. If 150 can be passed through a variable having default value 150 and will overridden by a value passed by ForceGraph3D function, it might work

@vasturiano
Copy link
Owner

@shikharka from v1.22.0 you can now specify a custom distance using cameraPosition. F.e:

myGraph.cameraPosition({ z: 1000 });

@shikharka
Copy link
Author

Thanks! will check

@Doni44
Copy link

Doni44 commented May 17, 2018

Hello, and is ther any wat to tell the graph not to move? I mean, the first time it'is like the 3D grapgh flies away from my div...

@vasturiano
Copy link
Owner

@Doni44 answered in #72.

@rdecapomaranca
Copy link

By exposing tbControls like you exposed camera and scene I was able to set the min and max zoom and also disable rotation which I needed to display a 2D graph. Could you maybe expose this, so that my code doesn't differ from the one on repository.

Thank you,
Nika

@shaliniBITC
Copy link

By exposing tbControls like you exposed camera and scene I was able to set the min and max zoom and also disable rotation which I needed to display a 2D graph. Could you maybe expose this, so that my code doesn't differ from the one on repository.

Thank you,
Nika

Hi, can you please explain how you set min and max zoom.

@vasturiano
Copy link
Owner

@shaliniBITC you can access the various config of TrackballControls via the .controls() method.
So, for min/max distance:

myGraph.controls().maxDistance = 2000;

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

5 participants