kieler / elkjs

ELK's layout algorithms for JavaScript
Other
1.8k stars 97 forks source link

Positioning of children nodes further down #302

Open bopeng95 opened 1 month ago

bopeng95 commented 1 month ago

Is there some property I need to apply that positions a child 2 levels down to be closer to the parent if the 1st level has a node with an insanely large height? (this applies to any children on any level) For Example: Elk JSON

Screenshot 2024-10-02 at 6 27 06 PM

I was able to use alignment: 'TOP' to have the 1st child node on the right positioned at the top, but my goal is to have the 2 left and right subtrees be independent of one another so that the 2nd child on the right will be positioned closer and not on the 3rd layer (below the maximum height node from 2nd layer)

I am trying to prevent having to create a subgroup per new child.

soerendomroes commented 1 month ago

You can try using a compaction strategy.

bopeng95 commented 1 month ago

ty for the response! it does work to a certain extent to what I was expecting, It could be part of the elk's algorithm but as I added more nodes in this example, node n9 is pushed to the bottom but alignment TOP did not work. For nodes 10, 11, 12, they are not evenly aligned at the top either (picture is something I was expecting)

Screenshot 2024-10-07 at 12 20 21 PM

If i add edgerouting POLYLINE, it is similar to what I need, but the compaction strategy does not work with edge routing is this correct?

bopeng95 commented 1 month ago

Here is another good example of n7 and n9 being pushed down, i think it is because the graph is trying to reduce the gap horizontally? and minimize empty space. My goal essentially would just be each child to be in its own tree regardless if it needs to push the sibling nodes out creating a big horizontal gap Example Screenshot 2024-10-07 at 1 10 55 PM

soerendomroes commented 1 month ago

If this is the case, I suggest introducing hierarchy to achieve this (and make the hierarchical node invisible).

bopeng95 commented 1 month ago

i see, seems like sub flow is the only way to achieve this, i would need to apply child to a child for every node. Not sure if I want to go that route.

Thanks for the help!