lempiy / flutter_graphite

Flutter widget to draw interactive direct graphs (flowcharts) of any complexity in a tile rectangular manner.
MIT License
166 stars 32 forks source link

Feature request: positioning nodes between children nodes #2

Closed orestesgaolin closed 1 year ago

orestesgaolin commented 4 years ago

Hi there! Thanks for sharing this awesome library. I wonder how to get the matrix that would place "parent" nodes in between "children" nodes.

Take a look at the example UI: image

I would like the node Filelinks Standard... to be placed in the middle as pointed by arrow. In other words the output matrix should look like:

const expectTest = '''
A-B│ A │A-D│
B  | C |D  |
''';
lempiy commented 4 years ago

@orestesgaolin Hello.

Currently, core package of library generates 2d matrix, which may be used to render through different types of renderers. You may find different core implementations in Go(ASCII rendering) and React.js (SVG rendering).

Because, 2d matrix is simply 2d array, its not so easy to "center" all nodes in graph. In your example, you have odd amount of children so it looks simple, but in case with even count of children, for instance - 2, matrix position of parent element would be 1.5 - which is hard to handle with "array" indexes.

I've made flutter port because, currently I'm working on my own project that uses this lib. In that project I don't need this kind of behaviour, because when you have a "wide" graph with huge amount of leafs at one level it might be less compact and less readable.

Anyway, I had a plan to implement this feature. Especially after InteractiveViewer was released.

Nevertheless, I cannot guarantee that it will happen in a near future (basically this year), cuz currently I'm busy with project mentioned above.