Como criar diagramas e gráficos com Markdown?

Como criar diagramas e gráficos com Markdown?

Mermaid te permite criar diagramas e visualizações usando texto e código.


Fluxograma

Formas de nós

simples
node
flowchart LR
node
quadrado
square node
flowchart LR
square[square node]
redondo
round node
flowchart LR
round(round node)
pílula
pill node
flowchart LR
stadium([pill node])
de sub-rotina
subroutine node
flowchart LR
subroutine[[subroutine node]]
cilíndrico
cylindrical node
flowchart LR
cylindrical[(cylindrical node)]
circular
circular node
flowchart LR
circular((circular node))
assimétrico
asymmetric node
flowchart LR
asymmetric>asymmetric node]
losango
rhombus node
flowchart LR
rhombus{rhombus node}
hexágono
hexagon node
flowchart LR
hexagon{{hexagon node}}
paralelogramo direito
right parallelogram node
flowchart LR
parallelogram_right[/right parallelogram node/]
paralelogramo esquerdo
left parallelogram node
flowchart LR
parallelogram_left[\left parallelogram node\]
trapézio para baixo
down trapezoid node
flowchart LR
trapezoid_down[/down trapezoid node\]
trapézio para cima
up trapezoid node
flowchart LR
trapezoid_up[\up trapezoid node/]
circular duplo
Syntax error in graph
flowchart LR
double_circular(((double circular node)))

Conexões de nós

Sólido
A
B
flowchart LR
A --- B
Pontilhado
A
B
flowchart LR
A -.- B
Espesso
A
B
flowchart LR
A === B
Com descrição
Sintaxe com pipe
description
A
B
flowchart LR
A --->|description| B
Sintaxe entre setas
description
A
B
flowchart LR
A --description-> B
Pontas de flecha
Padrão
A
B
flowchart LR
A --> B
Início
A
B
flowchart LR
A --o B
Fim
A
B
flowchart LR
A --x B
Multi directional
A
B
C
D
E
F
flowchart LR
A <--> B
C o--o D
E x--x F

Subgráficos

two
D
C
Label
B
A
flowchart TB
subgraph one[Label]
A --> B
end
subgraph two
C --> D
end
one --> two

Interações

A
B
C
D
flowchart LR
A-->B
B-->C
C-->D
click A href "http://localhost:3000"
click B href "https://www.github.com"

Sequência

Sintaxe

Participants
AliceBobHi BobHi AliceAliceBob
sequenceDiagram
participant Alice
participant Bob
Alice->>Bob: Hi Bob
Bob->>Alice: Hi Alice
Atores
AliceBobHi BobHi AliceAliceBob
sequenceDiagram
actor Alice
actor Bob
Alice->>Bob: Hi Bob
Bob->>Alice: Hi Alice
Apelidos
AliceJohnHello John, how are you?Great!AliceJohn
sequenceDiagram
participant A as Alice
participant J as John
A->>J: Hello John, how are you?
J->>A: Great!

Setas

ABSolid line without arrowDotted line without arrowSolid line with arrowheadDotted line with arrowheadSolid line with a cross at the endDotted line with a cross at the endSolid line with an open arrow at the end (async)Dotted line with a open arrow at the end (async)AB
sequenceDiagram
A->B: Solid line without arrow
A-->B: Dotted line without arrow
A->>B: Solid line with arrowhead
A-->>B: Dotted line with arrowhead
A-xB: Solid line with a cross at the end
A--xB: Dotted line with a cross at the end
A-)B: Solid line with an open arrow at the end (async)
A--)B: Dotted line with a open arrow at the end (async)

Ativações

ABactivate B+ A- Bdeactivate AAB
sequenceDiagram
A->>B: B
activate B
B->>+A: B
B->>-A: B
A->>B: B
deactivate A

Classe

Sintaxe

BankAccount
string owner
number balance
deposit(amount)
withdrawal(amount)
classDiagram
class BankAccount
BankAccount : string owner
BankAccount : number balance
BankAccount : deposit(amount)
BankAccount : withdrawal(amount)

Visibilidade

Visibility
+string public
-string private
#string protected
~string internal
string static
getStatic()
getAbstract()
classDiagram
class Visibility
Visibility: +string public
Visibility: -string private
Visibility: #string protected
Visibility: ~string internal
Visibility: string static$
Visibility: getStatic()$
Visibility: getAbstract()*

Relacionamentos

Inheritance
Composition
Aggregation
Association
Link(Solid)
Dependency
Realization
Link(Dashed)
classA
classB
classC
classD
classE
classF
classG
classH
classI
classJ
classK
classL
classM
classN
classO
classP
classDiagram
classA --|> classB : Inheritance
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Link(Solid)
classK ..> classL : Dependency
classM ..|> classN : Realization
classO .. classP : Link(Dashed)

Cardinalidade / Multiplicidade nas relações

1
*
1
1..*
Contains
many
Customer
Ticket
Student
Course
Galaxy
Star
classDiagram
Customer "1" --> "*" Ticket
Student "1" --> "1..*" Course
Galaxy --> "many" Star : Contains

Estado

Sintaxe

transition
stateNode
stateDiagram-v2
direction LR
[*] --> stateNode: transition
stateNode --> [*]

Composição

transition
mainState
subState
subSubState
stateDiagram-v2
direction LR
[*] --> mainState: transition
state mainState {
direction LR
[*] --> subState
state subState {
direction LR
[*] --> subSubState
subSubState --> [*]
}
subState --> [*]
}
mainState --> [*]

Choice

condition
false
true
stateDiagram-v2
state choice <<choice>>
[*] --> condition
condition --> choice
choice --> false
choice --> true

Forks

A
B
stateDiagram-v2
state fork <<fork>>
state join <<join>>
[*] --> fork
fork --> A
fork --> B
A --> join
B --> join
join --> [*]

Anotações

The state with a note
Important information! You can write
notes.
State2
This is the note to the left.
stateDiagram-v2
State1: The state with a note
note right of State1
Important information! You can write
notes.
end note
State1 --> State2
note left of State2 : This is the note to the left.

Concorrência

concurrency
transition
stateNode1
transition
stateNode2
stateDiagram-v2
direction LR
[*] --> concurrency
state concurrency {
direction TB
[*] --> stateNode1: transition
stateNode1 --> [*]
--
direction TB
[*] --> stateNode2: transition
stateNode2 --> [*]
}
concurrency --> [*]

Relacionamento de entidade

Sintaxe

CARNAMED-DRIVERPERSONallowsis
erDiagram
CAR ||--o{ NAMED-DRIVER : allows
PERSON ||--o{ NAMED-DRIVER : is

Relacionamentos

Um para um
oneto-onerelationship
erDiagram
one ||--|| to-one : relationship
Zero ou um
zero-oneto-zero-onerelationship
erDiagram
zero-one |o--o| to-zero-one : relationship
Zero ou mais
zero-moreto-zero-morerelationship
erDiagram
zero-more }o--o{ to-zero-more : relationship
Um ou mais
one-moreto-one-morerelationship
erDiagram
one-more }|--|{ to-one-more : relationship

Atributos

CARstringregistrationNumberstringmakestringmodelNAMED-DRIVERPERSONstringfirstNamestringlastNameintageallowsis
erDiagram
CAR ||--o{ NAMED-DRIVER : allows
CAR {
string registrationNumber
string make
string model
}
PERSON ||--o{ NAMED-DRIVER : is
PERSON {
string firstName
string lastName
int age
}

Jornada do usuário

CatMe
Go to work
Go to work
Me
Make tea
Make tea
Me
Go upstairs
Go upstairs
MeCat
Do work
Do work
Go home
Go home
Me
Go downstairs
Go downstairs
Me
Sit down
Sit down
My working day
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me

Gantt

Sintaxe

2022-11-012022-12-012023-01-012023-02-012023-03-012023-04-012023-05-012023-06-012023-07-012023-08-012023-09-012023-10-012023-11-012023-12-01default critical active critical active milestone milestone
gantt
default :a, 2022-10-08, 1w
critical :crit, b, 2022-10-08, 1d
active :active, c, after b a, 1d
critical active :crit, active, ca, after c, 1d
milestone : milestone, m1, 17:49, 2min
milestone : milestone, m2, 18:14, 1d

Gráfico de pizza

40%46%9%5%Key elements in Product XCalcium [42.96]Potassium [50.05]Magnesium [10.01]Iron [5]
pie showData
title Key elements in Product X
"Calcium" : 42.96
"Potassium" : 50.05
"Magnesium" : 10.01
"Iron" : 5

Requisitos

Sintaxe

<<Requirement>>test_reqId: 1Text: the test text.Risk: HighVerification: Test<<Element>>test_entityType: simulationDoc Ref: None<<satisfies>>
requirementDiagram
requirement test_req {
id: 1
text: the test text.
risk: high
verifymethod: test
}
element test_entity {
type: simulation
}
test_entity - satisfies -> test_req

Requisito

<<Requirement>>test_reqId: 1Text: the test text.Risk: HighVerification: Test
requirementDiagram
requirement test_req {
id: 1
text: the test text.
risk: high
verifymethod: test
}

Types:

  • requirement
  • functionalRequirement
  • interfaceRequirement
  • performanceRequirement
  • physicalRequirement
  • designConstraint

Risk:

  • Low
  • Medium
  • High

Verification Method:

  • Analysis
  • Inspection
  • Test
  • Demonstration

Gráfico do Git

%%{ init: { 'logLevel': 'debug', 'theme': 'dark' } }%%
gitGraph
commit id: "initial commit"
branch hom
branch feat/button
checkout feat/button
commit id: "create button"
commit id: "finish button"
checkout hom
merge feat/button
checkout feat/button
commit id: "fix hover"
checkout hom
merge feat/button
checkout feat/button
commit id: "fix accessibility"
checkout hom
merge feat/button
checkout main
merge hom