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

Can't find a way to add spacing between the top node of the subgraph and the subgraph name #3779

Open
dpal opened this issue Nov 9, 2022 · 4 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@dpal
Copy link

dpal commented Nov 9, 2022

Description

Consider the following graph:

    flowchart TD

        box1["No space above this box and the title"]

        subgraph Example of a subgraph that has no space between name and top node
             box1-->box2
    end

I could not find any way to add a space in such a graph.

Styling with "margin" does not work.
The vertical "margin" style setting is ignored.
The horizontal margin setting sort of works but works incorrectly (probably a separate bug). The margin adds space between the text inside a node and its border rather than to be a margin around the node itself.

  flowchart TD
        classDef withmargines margin:100px 5px 100px 5px;

        box1["No space above this box and the title"]:::withmargines
        

        subgraph foo [Example of a subgraph that has no space between name and top node]
             box1-->box2

        class foo withmargines;

    end

See the second screenshot.

Steps to reproduce

Create a graph as described in the mermaid online editor.

Note: Same result in HackMD.

Screenshots

Screenshot from 2022-11-09 17-01-33

Screenshot from 2022-11-09 17-21-43

Code Sample

No response

Setup

Desktop

  • OS and Version: RHEL Workstation 8.6
  • Browser and Version: Chrome

Additional Context

No response

@dpal dpal added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 9, 2022
@olivierduquenoy
Copy link

olivierduquenoy commented Nov 15, 2022

Try this :

flowchart TD

    classDef withmargines fill-opacity:0.0,color:#FFFFFF,stroke-width:0px;
    subgraph foo [<font size = 6>Example of a subgraph that HAS space between name and top node]

        foo1["<p style='width:100px;height:0px;margin:0'>Invisible !!!/p>"]:::withmargines
        box1["Some space above this box and the title"]
        
        foo1 ~~~ box1-->box2
    end

You can change the space with the height property of foo1

@dpal
Copy link
Author

dpal commented Nov 16, 2022

Try this :
...

This is a nice hack, thank you! It adds a hidden box at the top - OK. But it works around the problem (which is fine for me) but really does not fix the actual limitation of lack of support of margins and spacing. I think the issue is still valid as described.

@Ryder17z
Copy link

Related: mermaid-js/mermaid-live-editor#1410
I thought it was just an issue in the live editor...

@Ryder17z
Copy link

@olivierduquenoy Try this:

flowchart TD

    classDef withmargines fill-opacity:0.0,color:#FFFFFF,stroke-width:0px;
    subgraph foo [<font size = 6>Example of a subgraph that HAS space between\n name and top node but not when it has a linebreak]

        foo1["<p style='width:100px;height:0px;margin:0'>Invisible !!!/p>"]:::withmargines; 
        box1["Some space above this box and the title"];
        
        foo1 ~~~ box1-->box2["text here fa:fa-car fa:fa-dog fa:fa-toolbox"];
    end

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: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

3 participants