# Reorder and align the elements and the diagram

**URL:** <https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005>\
**Category:** Developers\
**Created:** [May 13, 2024, 5:52pm UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005 "2024-05-13T17:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alessia\_Volpi](https://forum.bpmn.io/user_avatar/forum.bpmn.io/alessia_volpi/32/5289_2.png) [@Alessia\_Volpi](https://forum.bpmn.io/u/Alessia_Volpi)\
**Post date:** [May 13, 2024, 5:52pm UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005/1 "2024-05-13T17:52:15Z")

</div>

Hi, I would like to ask if you know about some function that can be invoked and that re allign or reorder the entire diagram in bpmnjs.  
I recursively add other element to the diagram and in the end the entire diagram is a mess.  
So… exists some function that can help me?  
Thank in advance for the answer.

---

<div class="post-metadata">

**Author:** ![barmac](https://forum.bpmn.io/user_avatar/forum.bpmn.io/barmac/32/974_2.png) [@barmac](https://forum.bpmn.io/u/barmac)\
**Post date:** [May 14, 2024, 8:17am UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005/2 "2024-05-14T08:17:41Z")

</div>

Please share a running / prototypical example that clearly shows what you’re trying to achieve, what is working and what is not.

Use our existing [starter projects](https://github.com/bpmn-io/bpmn-js-examples/tree/master/starter) to quickly hack it or share your existing, partial solution on GitHub or via a [CodeSandbox](https://codesandbox.io/s/bpmn-js-starter-m3kex?file=/src/index.js). Provide the necessary pointers that allow us to quickly understand where you got stuck.

This way we may be able to help you in a constructive manner.

Thanks ❤

---

<div class="post-metadata">

**Author:** ![SeraBano](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@SeraBano](https://forum.bpmn.io/u/SeraBano)\
**Post date:** [June 25, 2024, 11:22am UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005/3 "2024-06-25T11:22:24Z")

</div>

> [@Alessia\_Volpi](#):
>
> Hi, I would like to ask if you know about some function that can be invoked and that re allign or reorder the entire diagram in bpmnjs.  
> I recursively add other element to the diagram and in the end the entire diagram is a mess.  
> So… exists some function that can [help](https://s9gamedownload.com/) me?  
> Thank in advance for the answer.

Some libraries have built-in functions for re-aligning or reordering elements. Have you checked if bpmn-js has a `layout` or `auto layout` function?

---

<div class="post-metadata">

**Author:** ![philippfromme](https://forum.bpmn.io/user_avatar/forum.bpmn.io/philippfromme/32/2803_2.png) [@philippfromme](https://forum.bpmn.io/u/philippfromme)\
**Post date:** [July 2, 2024, 8:27am UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005/4 "2024-07-02T08:27:26Z")

</div>

You can either use [Modeling#alignElements](https://github.com/bpmn-io/diagram-js/blob/develop/lib/features/modeling/Modeling.js#L582) or [Modeling#distributeElements](https://github.com/bpmn-io/diagram-js/blob/develop/lib/features/modeling/Modeling.js#L515) or lay out the diagram from scratch using [GitHub - bpmn-io/bpmn-auto-layout: Layout BPMN diagrams, generating missing DI information.](https://github.com/bpmn-io/bpmn-auto-layout). These are the options we offer. Anything else you’d have to build yourself.

---

<div class="post-metadata">

**Author:** ![system](https://forum.bpmn.io/uploads/default/original/2X/b/b534893973385c2d302b38572464112e4adae002.png) [@system](https://forum.bpmn.io/u/system)\
**Post date:** [July 9, 2024, 8:27am UTC](https://forum.bpmn.io/t/reorder-and-align-the-elements-and-the-diagram/11005/5 "2024-07-09T08:27:46Z")

</div>

Closed on July 9, 2024, 8:27am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
