Skip to content

flowgraph TB vs. TD difference, when using subgraphs #6681

@lesteral

Description

@lesteral

Description

https://mermaid.js.org/syntax/flowchart.html#direction states

Possible FlowChart orientations are:

  • TB - Top to bottom
  • TD - Top-down/ same as top to bottom

However, TB vs. TD gives different results for subgraphs, as shown in the attached images.

Is the documentation wrong, or is one of these results unexpected?

Steps to reproduce

flowchart TB
    subgraph one
        a2
        a1
    end
    subgraph two
        b2
        b1
    end
    a1 --> a2
    b1 --> b2
    one --> two

... results in:
Image

flowchart TD
    subgraph one
        a2
        a1
    end
    subgraph two
        b2
        b1
    end
    a1 --> a2
    b1 --> b2
    one --> two

results in:
Image

I confirmed this result in Live Editor - Develop - sample

Screenshots

No response

Code Sample


Setup

  • Mermaid version: Live Editor, v11.6.0 - as well as the Develop version (as of today, 6/23/25)
  • Browser and Version: Chrome 137.0.7151.123

Suggested Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions