kieler / elkjs

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

Node placement issue #306

Closed Abhishek-Shandilya closed 1 week ago

Abhishek-Shandilya commented 2 weeks ago

Hi, i have a drag and drop workflow where i am creating a loop.

Reproduction in elklive.

Expected behavior Evaluator Node and its children should be between entry and exit.

Screenshots When i add evaluator node with its children this happens. This doesnt work: image

But when a single node is added it works correctly. This works: image

i would like to know what is the issue here and how to fix it.

layoutOptions used:

'elk.algorithm': 'layered',
'elk.direction': 'DOWN',
'elk.alignment': 'CENTER',
'elk.spacing.nodeNode': '140',
'elk.spacing.componentComponent': '60',
'elk.layered.spacing.baseValue': '80',
'elk.layered.nodePlacement.strategy': 'NETWORK_SIMPLEX',
'elk.layered.crossingMinimization.strategy': 'LAYER_SWEEP',
'elk.layered.considerModelOrder.strategy': 'NONE',
'elk.partitioning.activate': 'true',
'elk.edgeRouting': 'ORTHOGONAL',
'elk.spacing.individualSettings': 'true',
'elk.spacing.edgeNode': '120',
'elk.spacing.edgeEdge': '60',
'elk.hierarchyHandling': 'INCLUDE_CHILDREN',
'elk.contentAlignment': 'H_CENTER',
'elk.nodeLabels.placement': 'INSIDE V_CENTER H_CENTER',
'elk.layered.mergeEdges': 'true',
'elk.edge.splines': 'true',
soerendomroes commented 2 weeks ago

Hi, I must guess what is wrong, since you did not reproduce the issue in elklive.

It might depend on the cycleBreaking strategy you are using and potentially on the partitions you might set. Maybe try setting the cycleBreaking.strategy to either GREEDY_MODEL_ORDER or to DEPTH_FIRST. If this does not solve the issue, I would like you to reproduce your problem in elklive.

Abhishek-Shandilya commented 2 weeks ago

Hi, thanks for the quick reply.

Reproduction in elklive.

Maybe try setting the cycleBreaking.strategy to either GREEDY_MODEL_ORDER or to DEPTH_FIRST.

thanks, this did fix my issue. Screenshot 2024-11-08 100522

but now there is an issue with the side edges, the side edges of the loop start and loop end doesnt change when the children node goes wide, do i need to attach a port on both side to fix that?

Is there any documentation i could read to learn about all of this, which is easy to approach.

soerendomroes commented 2 weeks ago

Here are a few examples for some use cases. Otherwise, all layout options of the layered algorithm are documented here. In terms of order in your drawing, I recommend reading this blogpost. What exactly is all of this for you?

Is this what you want to achieve?

Abhishek-Shandilya commented 2 weeks ago

What exactly is all of this for you?

I don't understand the question.

Is this what you want to achieve?

Yes, but currently there are some spacing issues.

I don't want to keep asking as the original node placement issue is resolved but can you suggest how to fix this spacing.

Screenshot 2024-11-08 150253

soerendomroes commented 2 weeks ago

Yes, but currently there are some spacing issues.

I don't want to keep asking as the original node placement issue is resolved but can you suggest how to fix this spacing.

Yes, the issues is that the rendering of your nodes does not match the size that ELK thinks your nodes have. Hence, if your nodes have a fixed rendering size, you should add this as a nodeSize.minimum and add MINIMUM_SIZE to your nodeSize.constraints.

soerendomroes commented 2 weeks ago

I don't understand the question.

You stated "Is there any documentation i could read to learn about all of this, which is easy to approach." To answer that I need to know more specifically what you mean by "all of this".

Abhishek-Shandilya commented 2 weeks ago

I'll try adding a minimum size to all nodes.

And by all of this i meant layoutOptions, to create my own understanding of how its working and how can i manipulate it, The elk documentation & reference material does provide all the options but lacks in examples differentiating between the options. The examples page provides some use-cases.

What my initial question was: An easy to approach documentation or guideline to build graphs with elk which could help me solve my questions.

Abhishek-Shandilya commented 2 weeks ago

This is my layoutOptions for a single node: { 'nodeSize.constraints': "MINIMUM_SIZE", 'nodeSize.minimum':(${width}, ${height}) }

This doesnt solve the edge-node overlapping issue though.

if i increase the width or height by adding some padding this happens: image you can see a slight gap on the right side.

soerendomroes commented 2 weeks ago

Ok, but this is most likely not an issue in ELK. I suppose the size calculation of the rendering size is wrong. Have you confirmed that the rendering really has the size you give to ELK? Have you tried to parametrize your rendering based on the minimum size you set in ELK?

Abhishek-Shandilya commented 1 week ago

It appears that the minimum size is being correctly calculated by ELK and rendered accordingly, so no discrepancy is apparent there. On closer examination, the crossing line within the node aligns precisely with the node's padding. This observation suggests that ELK might not be accounting for padding in its layout calculations. I will conduct further tests focusing on padding configurations to confirm. It may be necessary to explicitly specify padding to ensure ELK incorporates it into the layout as intended.

Abhishek-Shandilya commented 1 week ago

i will be closing this issue as i think we have resolved the node placement issue.

Thanks again.