microsoft / microsoft/automatic-graph-layout
Pan and zoom to specific node via code
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
I'm trying to pan and zoom to a specific node.
For the zoom the issue is that when setting the ZoomF value, it is still 1 after the line with the assignment and nothing happens:
graphViewer.ZoomF = 2;
Regarding panning to a node I'm not sure how to calculate the values for the Pan() method.
First I'm getting the position of the node:
var node = graphViewer.Graph.FindNode(id);
Then using than node.Pos value I need somehow get the offset for the Pan() method. If I understand it correctly the Pan() method expects the difference, not the absolute position.
The current offset when panning seems to be available in graphViewer.Transform.Offset. Without any zooming and panning the X value is 0 and the Y value seems to be the height of the graphViewer control.
Does the zoom level also have to be taken into account? Can the Pan offset be calculated using Transform.Offset and the node position?
Similar question, but without an answer:
Zoom and pan programatically?
https://github.com/microsoft/automatic-graph-layout/issues/227
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the graphViewer.ZoomF, Pan(), Transform.Offset, and node.Pos APIs, then review the related issue 227. Done means documenting or correcting a way to zoom and pan programmatically to a specific node, including whether the zoom level affects the offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100