- Notifications
You must be signed in to change notification settings - Fork1.6k
How do I calculate the camera state to zoom to a selection of nodes in the graph#1461
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hi I would like to select a couple of nodes and then provide a method to zoom the camera so that the selected nodes are centered and all visible. In the end I think I need to set the cameras state So far I can calculate Thanks for any help! Ben |
BetaWas this translation helpful?Give feedback.
All reactions
You can now use thefitViewportToNodes
helper from the new@sigma/utils package.
You can try it inthis story.
Replies: 2 comments 6 replies
-
This is indeed a bit hard to do, so I'm planning to release it as a function exported from a new upcoming |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hey Alexis! Thank you so much! That would be super convenient. Many thanks for all your efforts! Best Benny |
BetaWas this translation helpful?Give feedback.
All reactions
-
You can now use the |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi@jacomyal, I was testing out the What I was going for was to click a button to zoom out and fit the entire graph. Maybe this feature already exists and I've messed something up though. |
BetaWas this translation helpful?Give feedback.
All reactions
-
This is the intended behavior, from what I understand:
What do you exactly by "a button to zoom out and fit the entire graph"? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ah ok. I thought that was the case and this is actually helpful because it means I'm doing something to make the camera not bring all the nodes into view. Also, I'm happy to move this to a new discussion if that's helpful but I'll explain what I'm doing here. I have a graph that initially loads from the database and displays as expected with a forceAtlas2 worker running. I'm using react-sigma camera controls and specifically the reset function that calls I then implemented an expand function that is similar to the linkcurious expand shown here:https://doc.linkurious.com/user-manual/latest/expand/ The way I implemented expand is when I click on a node it executes a query and merges the results with the existing graph. Here's a simplified snippet of the code below:
After the expand or even dragging a node a node outside of the view what I was hoping to have is a button that would zoom in or out to fit the entire graph in the view. How would I go about doing that? I'm still new to sigma so my apologies if this is obvious. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi@Rich5, As I consider the initial question solved with the new |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sounds good. I really appreciate it. Moved to:#1471 |
BetaWas this translation helpful?Give feedback.