Open SamHasler opened 2 years ago
Upon reflection I think I've misunderstood how direction affects layout, so I'm wrong about the first issue. The other points still appear to be inconsistencies though:
Adding links shows more inconsistencies between graph/flowchart:
flowchart TB
N1
subgraph Default
D1
D2
end
N2
subgraph TopToBottom
direction TB
TB1
TB2
end
N3
subgraph LeftToRight
direction LR
LR1
LR2
end
subgraph RightToLeft
direction RL
RL1
RL2
end
N4
N5
N4 --> N5
D1 --> D2
TB1 --> TB2
LR1 --> LR2
RL1 --> RL2
graph TB
graph
appears to have only one direction through all subgraphs
it works well if you don't connect them:
flowchart TB
subgraph TopToBottom
direction TB
TB1
TB2
end
subgraph LeftToRight
direction LR
LR1
LR2
end
TB1 --> TB2
LR1 --> LR2
flowchart TB
subgraph TopToBottom
direction TB
TB1
TB2
end
subgraph LeftToRight
direction LR
LR1
LR2
end
TB1 --> TB2
LR1 --> LR2
But if you connect them it only uses one direction:
flowchart TB
subgraph TopToBottom
direction TB
TB1
TB2
end
subgraph LeftToRight
direction LR
LR1
LR2
end
TB1 --> TB2
TB2 --> LR1
LR1 --> LR2
flowchart TB
subgraph TopToBottom
direction TB
TB1
TB2
end
subgraph LeftToRight
direction LR
LR1
LR2
end
TB1 --> TB2
TB2 --> LR1
LR1 --> LR2
But if you connect them it only uses one direction:
https://mermaid-js.github.io/mermaid/#/flowchart?id=direction-in-subgraphs -> A clarification is in order here. at the bottom
Yeah, but it's still not that simple.
Let's start with the fact that TD
and TB
layout are different, despite being documented as interchangeable synonyms.
flowchart TB
flowchart TB
subgraph SUB1
A
B
C
end
subgraph SUB2
direction LR
D
E
end
subgraph SUB3
direction LR
DB[(Database)]
F
end
DB -.- F
SUB1 --> SUB2
SUB3 -.- SUB2
SUB1 --> SUB3
flowchart TD
flowchart TD
subgraph SUB1
A
B
C
end
subgraph SUB2
direction LR
D
E
end
subgraph SUB3
direction LR
DB[(Database)]
F
end
DB -.- F
SUB1 --> SUB2
SUB3 -.- SUB2
SUB1 --> SUB3
The ONLY code change between those two graphs is starting with flowchart TB
vs. flowchart TD
.
(Ah, I see @SamHasler actually had already covered that in the initial report. My apologies.)
Actually, here's an even better one: Why is inserting direction TD
into a subgraph a parse error?
flowchart TD
subgraph SUB1
A
B
C
end
subgraph SUB2
direction LR
D
E
end
subgraph SUB3
direction TD
DB[(Database)]
F
end
DB -.- F
SUB1 --> SUB2
SUB3 -.- SUB2
SUB1 --> SUB3
direction TB
works just fine:
flowchart TD
subgraph SUB1
A
B
C
end
subgraph SUB2
direction LR
D
E
end
subgraph SUB3
direction TB
DB[(Database)]
F
end
DB -.- F
SUB1 --> SUB2
SUB3 -.- SUB2
SUB1 --> SUB3
flowchart TD
subgraph SUB1
A
B
C
end
subgraph SUB2
direction LR
D
E
end
subgraph SUB3
direction TB
DB[(Database)]
F
end
DB -.- F
SUB1 --> SUB2
SUB3 -.- SUB2
SUB1 --> SUB3
Hello any update on this? I get the same error.
Taking this graph:
and changing only the first line it renders as follows:
(rendered on mermaid.live on 2022/03/03 version 8.14.0)
Note that: