-
-
Notifications
You must be signed in to change notification settings - Fork 114
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 scale and center a graph so that the whole graph is visible #91
Comments
have you found a solution by any chance? |
is this answered? |
I did it like this Which results in smth like this |
I stumbled accross the same issue and here's my solution that is more dynamic (works well when the child graph is smaller than the viewport as well as bigger) @override
Widget build(BuildContext c) {
return InteractiveViewer(
constrained: false,
boundaryMargin: const EdgeInsets.all(100),
minScale: 0.01,
maxScale: 5.6,
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: MediaQuery.of(context).size.width,
minHeight: MediaQuery.of(context).size.height,
),
child: Center(
child: GraphView(
graph: graph,
algorithm: BuchheimWalkerAlgorithm(builder, TreeEdgeRenderer(builder)),
paint: Paint()
..color = Constant.primaryColor
..strokeWidth = 1
..style = PaintingStyle.stroke,
builder: (Node node) => (node as MNode).builder(context, draggedTarget),
),
),
),
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the great package!
I am trying to show a graph and I want that it is centered and scaled to a size so that the whole graph is visible.
Is this possible?
This is what I have:
![drawing](https://user-images.githubusercontent.com/51273483/191104817-41c9a35d-0828-43f2-9a65-bbcfced98268.png)
This is what I would like to have:
![drawing](https://user-images.githubusercontent.com/51273483/191105076-c6ff5f29-b4ef-4201-bdaf-c99dadfe7b34.png)
The text was updated successfully, but these errors were encountered: