drawio-desktop icon indicating copy to clipboard operation
drawio-desktop copied to clipboard

Automatic tree layout child nodes in wrong order

Open haiyulin opened this issue 11 months ago • 8 comments

Preflight Checklist

  • [x ] I agree to follow the Code of Conduct that this project adheres to.
  • [x ] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

You must agree to search and the code of conduct. You must fill in this entire template. If you delete part/all or miss parts out your issue will be closed.

Describe the bug Automatic tree layout child nodes in wrong order.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'layout'
  2. Click on 'tree layout'
  3. Automatic tree layout child nodes in wrong orderr

Expected behavior When I set up automatic tree layout, the first-level child nodes behind the root node are not arranged in the order I placed them. How do I set this up?

Screenshots

draw.io version (In the Help->About menu of the draw.io editor):

  • draw.io version v23.1.5

Desktop (please complete the following information):

  • OS: Windows

Additional context

haiyulin avatar Mar 06 '24 05:03 haiyulin

Use these buttons: Screenshot 2024-03-06 at 06 34 30

alderg avatar Mar 06 '24 05:03 alderg

使用这些按钮: 屏幕截图 2024-03-06 于 06 34 30

hi, thank you for your answer.

I set up the nodes following this method, but the order still doesn't change. For example: the order of first-level child nodes from top to bottom is 1, 2, 3, 4, 5, 6. After applying automatic horizontal tree layout, the node order becomes 4, 5, 6, 1, 2.

haiyulin avatar Mar 06 '24 05:03 haiyulin

Please add a screenshot or a test case

alderg avatar Mar 06 '24 05:03 alderg

Please add a screenshot or a test case

Please see the use case at this link https://drive.google.com/file/d/1V57JOEN3czc2YlfgQmNcOx6yYw2FSM6Z/view?usp=sharing

haiyulin avatar Mar 06 '24 06:03 haiyulin

请添加屏幕截图或测试用例

请通过此链接查看用例 https://drive.google.com/file/d/1V57JOEN3czc2YlfgQmNcOx6yYw2FSM6Z/view?usp=sharing

Supplement, I just forgot to set the editability of this file. Now it has been corrected and the test can be edited.

haiyulin avatar Mar 06 '24 06:03 haiyulin

After a long period of debugging, I finally found the cause of the problem.

The ordering rules of child nodes in automatic tree layout are based on the creation time of the child node connecting lines. If I modify the properties of a sub-node connection line (for example: constraint direction, front and back position in graphics options), the creation time (sequence) of the connection line (sub-node) will be disrupted. If you reapply automatic tree layout at this time, the order of the child nodes will change to the order after changing the connection line properties.

I think this layout rule method is unreasonable, the user experience is very bad, and there are no relevant instructions in the user manual document. The sorting of child nodes in automatic layout is best sorted according to the xy coordinates of the child nodes.

The alternative I've found so far is to delete all related connecting lines and create new connecting lines for each related child node in the new order.

I'm a beginner in drawio and don't know if there is a better solution. If anyone has a better solution, I would be very grateful.

haiyulin avatar Mar 06 '24 08:03 haiyulin

Ok there's a work around for this issue. The ordering rules are actually based on the date the child node was created and therefore the order of the child nodes in the definition. If you edit the XML for the diagram (save first) using Extras > Edit Diagram and change the order of the child nodes in there it will lay them out correctly.

canine-afficionado avatar Jul 05 '24 04:07 canine-afficionado

Layout -> Customs... does't work on Windows 10 18362.1256

draw.io-24.7.5-windows-no-installer.exe

[ { "layout": "mxCircleLayout", "config": { "radius": 30, "x0": 100, "y0": 60, } } ] But online version is ok.

Jeangowhy avatar Aug 23 '24 12:08 Jeangowhy