nabil6391 / graphview

Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
MIT License
420 stars 114 forks source link

Graph does not scale properly when first created #74

Open Quixotical opened 2 years ago

Quixotical commented 2 years ago

When first creating a tree graph, I create the tree and it stays locked to the top left of the screen. Then I scale by 2 finger pinching, and it immediately snaps to take up all available space on the screen. I have not been able to find a way to fix this yet, and it makes things look a little unpolished if the graph starts looking smaller, then you pinch and it snaps to be a lot larger and it's placement moves on the screen

Expectation

The graph can start in the same position and as expanded as it will be after pinching screen when it is first created. Without this, the graph looks sort of hacked together.

Before pinching

Screenshot from 2022-03-02 19-33-48

After pinching

Screenshot from 2022-03-02 19-34-53

Conclusion

As you can see, the graph has moved to be centered and is much larger, even though I did the smallest amount of pinch scaling as possible (After this initial pinch scale, the scaling is smooth and it no longer moves the placement of the graph again)

lischilpp commented 1 year ago

Here is an easy way to reproduce it: In the example https://github.com/nabil6391/graphview/blob/master/example/lib/tree_graphview.dart change level separation to 15 instead of 150. Run the demo app and it the graph will snap down after the first zoom gesture.

This bug seems to always occur, when the graph is smaller than the view. If the graph is larger then it works properly.