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

In flowcharts, how to get the graph lines to come out of vertices of the decision box #3260

Open
rishavs opened this issue Jul 25, 2022 · 8 comments
Labels

Comments

@rishavs
Copy link

rishavs commented Jul 25, 2022

Using the example in mermaid.live for flowcharts, I can create a nice flowchart - but the decision box ("is true?") has the graph arrows to the next steps coming out of its body.
Here is what I get today
image

Instead, I would want the lines to come out of the vertices of the decision box - something like this;
image

Is there a way to define my charts to push the graphing lines from the vertices today? If not, can I make this Feature Request?
The flowcharts just feel far more organized and pleasing that way.

@rishavs rishavs added the Type: Other Not an enhancement or a bug label Jul 25, 2022
@github-actions github-actions bot added the Status: Triage Needs to be verified, categorized, etc label Jul 25, 2022
@flywire
Copy link
Contributor

flywire commented Aug 7, 2022

Maybe by setting curve, see https://stackoverflow.com/questions/72538993/mermaid-flowchart-line-style.

Include your code so others can test.

@rishavs
Copy link
Author

rishavs commented Aug 8, 2022

Hi @flywire . The code I used is the sample chart code in mermaid live editor for flowcharts.

graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]

while renders to

graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]
Loading

I tried the curve options including stepBefore, but none of them cause the arrows to come out of the vertices.

@flywire
Copy link
Contributor

flywire commented Aug 8, 2022

No, but %%{init: {'flowchart' : {'curve' : 'stepAfter'}}}%% is pretty close:

image
Click image to open in mermaid.live

Using %%{init: {'flowchart' : {'curve' : 'stepBefore'}}}%%:

image
Click image to open in mermaid.live

The bug seems to be the lines don't originate from the centre of the node.

In a normal flowchart there should be a single path from the node before they diverge. A decision node is different.

@rishavs
Copy link
Author

rishavs commented Aug 15, 2022

The bug seems to be the lines don't originate from the centre of the node.

That might be it. I think just having that as a config might be good too.

@flywire
Copy link
Contributor

flywire commented Oct 20, 2022

Linear Curve is better:

image

@sidharthv96
Copy link
Member

flowchart-elk will do the job.

image
flowchart-elk TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]
Loading

@flywire
Copy link
Contributor

flywire commented Aug 1, 2023

flowchart-elk will do the job.

No, does not work for an even number of nodes and badly screws the order.

Original:

image

link

-elk:

image

link

@sidharthv96 sidharthv96 reopened this Aug 2, 2023
@sidharthv96
Copy link
Member

image

With even number of nodes. I think tweaking the elk rendering logic should fix this.

@sidharthv96 sidharthv96 added Type: Bug / Error Something isn't working or is incorrect Contributor needed Status: Approved Is ready to be worked on Graph: Flow Good first issue! Area: Development Status: Awaiting PR Internals: Renderer and removed Type: Other Not an enhancement or a bug Status: Triage Needs to be verified, categorized, etc labels Aug 2, 2023
@jgreywolf jgreywolf added the roadmap items to add to roadmap for auto workflow label Nov 16, 2023
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

4 participants