Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence diagram arrows only go left to right #825

Open
philsturgeon opened this issue Apr 21, 2019 · 18 comments
Open

Sequence diagram arrows only go left to right #825

philsturgeon opened this issue Apr 21, 2019 · 18 comments
Labels

Comments

@philsturgeon
Copy link

Arrows must be left to right, trying to do right to left causes errors:

sequenceDiagram
  A -> B: Thing
  A <- B: Return
Parse error on line 3:
... A -> B: Thing  A <- B: Return
----------------------^
Expecting 'NL', 'AS', ',', 'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'TXT', got '-'

This is something I was using in my PlantUML diagrams but it seems like Mermaid doesn't like it. Is this something you'd like to see added?

@alarobric
Copy link

If you read the docs carefully this is supported, you just need to write B-> A: Return instead.

@philsturgeon
Copy link
Author

@alarobric if you read what I wrote carefully you'd see that I know that. 😆

Arrows must be left to right

B -> A is left to right.

I just wanted to suggest this as a portability improvement.

@knsv knsv added Type: Enhancement New feature or request Contributor needed labels Jun 30, 2019
@knsv
Copy link
Collaborator

knsv commented Jun 30, 2019

That makes sense for compatability. Ideally mermaid should handle the PlantUML syntax. I will add this to the "backlog" but I cant promise any release date. This is a good starter task.

@IOrlandoni
Copy link
Member

IOrlandoni commented Jul 12, 2019

I'd be happy to work on this.

I need some validation in how the right to left arrows will stack with the shortcut for activation. PlantUML does not have shorcuts like mermaid, that I could find.

Currently, the shortcut is documented as a "suffix to the arrow". Keeping the shortcut as a suffix might cause issues in cases like a deactivation:
Actor1<--Actor2: Is this a dotted line or a deactivation?

I believe we should also use it as a prefix to the right to left arrows. Like so:
Actor1+<--Actor2: Activation of Actor1
Actor2-<--Actor1: Deactivation of Actor1

Does this make sense?

@ThePenguin1140
Copy link

What you posted makes sense. I don't know about expanding the syntax like that though. Would that prefix be required? What about regular left to right arrows?

I'd be more curious about the shortcut functionality. If it's not used maybe we should get rid of it in favor of this feature?

@IOrlandoni IOrlandoni added Status: Approved Is ready to be worked on and removed Contributor needed labels Jul 14, 2019
@IOrlandoni
Copy link
Member

Sorry, thought it would be a bit easier. I have some work in this branch but can't finish.
Given arrows like x--, some of the corner cases that kicked my butt are:
Alex --> Xena
Alex x-- Xena

Returned the issue to the pool.

@IOrlandoni IOrlandoni removed their assignment Jul 23, 2019
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you are still interested in it, and it is still relevant, you can comment or remove the label to revive it.

@github-actions github-actions bot added the Type: New Shape Request for new shape label Sep 24, 2019
@philsturgeon
Copy link
Author

@dunning-kruger could you make a PR for your progress? The GitHub Actions bot is gonna close this one eventually.

@IOrlandoni
Copy link
Member

@philsturgeon I'd rather not do a PR for something that does not work. My work in progress was left here: https://github.com/Dunning-Kruger/mermaid/tree/feature/right-to-left-arrows

@stale stale bot removed the Type: New Shape Request for new shape label Sep 26, 2019
@sesm
Copy link

sesm commented Sep 26, 2019

Picking this up if no objections.

@whitelizard
Copy link

Hi!

I was actually trying in a flow chart to have an arrow in the opposite direction, and finally found this issue.

My view and suggestion is that "logically" it could be a forward arrow, in how the layout and internal logic is handled, but the feature could perhaps simply be to enable ability to render an arrow in the opposite direction?

@jgreywolf
Copy link
Contributor

@sesm Any update?

@AnnoyingTechnology
Copy link

Also interested in an update on this.

@sesm sesm removed their assignment Apr 13, 2023
@sesm
Copy link

sesm commented Apr 13, 2023

No time to work on this right now, sorry for not providing a timely update.

@cstrempfer
Copy link

Sounds trivial, but this is holding me back from migrating PlantUML to Mermaid. It's not only the effort for replacing the arrows, it's also much harder to read than PlantUML syntax - even though ltr and rtl are logically the same.

@koson
Copy link

koson commented May 17, 2024

I'm afraid I don't understand your actual need, but I've found something interesting on Mermaid.
You can arrange objects by the order you need at the top of the diagram (from the left to the right) like these:

sequenceDiagram
    participant Account
    actor Teller
    actor Customer

    Customer -->> +Teller : Deposit some money
    Teller -->> Customer : please wait... 
    Teller -->> +Account : add money
    Account -->> -Teller : return balance
    Teller -->> -Customer : It's your balance

and the result is

sequenceDiagram
    participant Account
    actor Teller
    actor Customer

    Customer -->> +Teller : Deposit some money
    Teller -->> Customer : please wait... 
    Teller -->> +Account : add money
    Account -->> -Teller : return balance
    Teller -->> -Customer : It's your balance
Loading

@cstrempfer
Copy link

Hi @koson, this request is about the definition syntax, not the visualization. In the code you can only use ltr arrows.

@whitelizard
Copy link

I know that this issue is mainly about compatibility/portability. But as I initially found this discussion only for mermaid feature reasons, and for others that do, I found the following syntax for also controlling order of things in graphs (in addition to what @koson highlighted above):

flowchart LR
  B ~~~ A
  A --> B
flowchart LR
  B ~~~ A
  A --> B
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests