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
424 stars 117 forks source link

Index out of range #20

Closed jrheisler closed 3 years ago

jrheisler commented 3 years ago

I'm not sure if this is exactly related, but this is what happens. I am moving from 0.6.1 - 0.6.5, the orientation works fantastically, thank you. But there seems to be something going when changing out edges and nodes.

I am driving this from a database. Data comes in, map to a list of objects that define the nodes and arrows.

With 0.6.1 this works fine, as I am not sure what nodes I will be drawing each time, they all go away, along with the edges:

graph.edges.clear(); graph.nodes.clear();

I have also done this:

List<gv.Edge> edges = [];
graph.edges.forEach((element) {edges.add(element);});
graph.removeEdges(edges);

List<gv.Node> nodes = [];
graph.nodes.forEach((element) {nodes.add(element);});
graph.removeNodes(nodes);

Both works great for 0.6.1

But, 0.6.5 I get the attached error Screenshot (277)

jrheisler commented 3 years ago

Fyi, it results in a chart that looks like this: Screenshot (284)

jrheisler commented 3 years ago

After further testing, code changing... it appears that there is something going on when I am drawing subsets of a tree or a single node tree. There is an index of or different than it was used in 0.6.1.

Not sure if this is important, but I also can not run with InteractiveViewer( constrained: true... not something new, I never have gotten it to work correctly constrained, don't think I need to, it all works in 0.6.1. Let me know if you need more info.

Thank you!!!

vin-fandemand commented 3 years ago

Hey ! got the same issue here... would be nice if this could be fixed

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following IndexError was thrown during performLayout():
RangeError (index): Index out of range: index should be less than 2: 2

The relevant error-causing widget was:
  GraphView$
  file:///home/vin-fandemand/Documents/GitHub/importConfig/lib/workflowbuilder/widgets/dagTab/layerGraphView.dart.dart:23:20

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 216:49  throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 579:7             _get]
packages/graphview/layered/SugiyamaAlgorithm.dart 738:73                      assignY
packages/graphview/layered/SugiyamaAlgorithm.dart 330:5                       coordinateAssignment
packages/graphview/layered/SugiyamaAlgorithm.dart 42:5                        run
nabil6391 commented 3 years ago

Fixed, plz check 0.6.6y

jrheisler commented 3 years ago

Perfect, thank you!!!