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

Partial overlap of flowchart subgraph #4990

Open
QazCetelic opened this issue Oct 27, 2023 · 3 comments
Open

Partial overlap of flowchart subgraph #4990

QazCetelic opened this issue Oct 27, 2023 · 3 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request

Comments

@QazCetelic
Copy link

QazCetelic commented Oct 27, 2023

Proposal

Mermaid-JS should allow flowchart subgraphs to overlap to display complex groupings.
I propose that the end keyword is able to take the identifier of a subgraph as parameter to close. It should remain the current functionality when no argument is given. Placing the identifier after end could cause issues with the parser confusing it with new declarations, therefore I suggest the following Regex as syntax: end:\s?ID.

+

  • Allows creating charts that are currently impossible to represent

-

  • Could degrade performance of layout generation
  • Slightly increases complexity of syntax

Syntax example

flowchart TD
    subgraph one
    a
    subgraph two
    b
    end: one
    c
    subgraph three
    d
    end: two
    e
    %% Notice that this does not specify the subgraph
    end
    
    a --> b --> c --> d --> e

Layout example

image

@QazCetelic QazCetelic added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Oct 27, 2023
@jgreywolf jgreywolf added include and removed include labels Nov 16, 2023
@MVittiS
Copy link

MVittiS commented Feb 15, 2024

I agree with the feature request, but disagree on syntax.

Mermaid's declarative syntax already allows you to specify nodes independently from subgraphs, so the following expression already works:

graph TB
    A[Node A] --> B[Node B]
    C[Node C] --> D[Node D]
    
    subgraph Subgraph 1
        A
        D
    end

    subgraph Subgraph 2
        B
        C
    end    

grafik

What I would like to see is just support for the same node to span two different subgraphs using the same notation, so @QazCetelic 's example would instead be expressed as:

graph TB
    A[A] --> B[B]
    B[B] --> C[C]
    C[C] --> D[D]
    D[D] --> E[E]
    
    subgraph 1
        A
        B
    end

    subgraph 2
        B
        C
        D
    end

    subgraph 3
        D
        E
    end

@ediw8311xht
Copy link

This would be awesome to add.

@NewZsh
Copy link

NewZsh commented May 14, 2024

I also have the same feature request. But by now, I recommend to color the nodes with the same color in a subgraph to meet this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants