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
flowchart LR node
quadrado
flowchart LR square[square node]
redondo
flowchart LR round(round node)
pílula
flowchart LR stadium([pill node])
de sub-rotina
flowchart LR subroutine[[subroutine node]]
cilíndrico
flowchart LR cylindrical[(cylindrical node)]
circular
flowchart LR circular((circular node))
assimétrico
flowchart LR asymmetric>asymmetric node]
losango
flowchart LR rhombus{rhombus node}
hexágono
flowchart LR hexagon{{hexagon node}}
paralelogramo direito
flowchart LR parallelogram_right[/right parallelogram node/]
paralelogramo esquerdo
flowchart LR parallelogram_left[\left parallelogram node\]
trapézio para baixo
flowchart LR trapezoid_down[/down trapezoid node\]
trapézio para cima
flowchart LR trapezoid_up[\up trapezoid node/]
circular duplo
flowchart LR double_circular(((double circular node)))
Conexões de nós
Tipos de links
Sólido
flowchart LR A --- B
Pontilhado
flowchart LR A -.- B
Espesso
flowchart LR A === B
Com descrição
Sintaxe com pipe
flowchart LR A --->|description| B
Sintaxe entre setas
flowchart LR A --description-> B
Pontas de flecha
Padrão
flowchart LR A --> B
Início
flowchart LR A --o B
Fim
flowchart LR A --x B
Multi directional
flowchart LR A <--> B C o--o D E x--x F
Subgráficos
flowchart TB subgraph one[Label] A --> B end subgraph two C --> D end one --> two
Interações
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
sequenceDiagram participant Alice participant Bob Alice->>Bob: Hi Bob Bob->>Alice: Hi Alice
Atores
sequenceDiagram actor Alice actor Bob Alice->>Bob: Hi Bob Bob->>Alice: Hi Alice
Apelidos
sequenceDiagram participant A as Alice participant J as John A->>J: Hello John, how are you? J->>A: Great!
Setas
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
sequenceDiagram A->>B: B activate B B->>+A: B B->>-A: B A->>B: B deactivate A
Classe
Sintaxe
classDiagram class BankAccount BankAccount : string owner BankAccount : number balance BankAccount : deposit(amount) BankAccount : withdrawal(amount)
Visibilidade
classDiagram class Visibility Visibility: +string public Visibility: -string private Visibility: #string protected Visibility: ~string internal Visibility: string static$ Visibility: getStatic()$ Visibility: getAbstract()*
Relacionamentos
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
classDiagram Customer "1" --> "*" Ticket Student "1" --> "1..*" Course Galaxy --> "many" Star : Contains
Estado
Sintaxe
stateDiagram-v2direction LR [*] --> stateNode: transition stateNode --> [*]
Composição
stateDiagram-v2direction LR [*] --> mainState: transition state mainState { direction LR [*] --> subState state subState { direction LR [*] --> subSubState subSubState --> [*] } subState --> [*] } mainState --> [*]
Choice
stateDiagram-v2 state choice <<choice>> [*] --> condition condition --> choice choice --> false choice --> true
Forks
stateDiagram-v2 state fork <<fork>> state join <<join>> [*] --> fork fork --> A fork --> B A --> join B --> join join --> [*]
Anotações
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
stateDiagram-v2direction LR[*] --> concurrencystate concurrency { direction TB [*] --> stateNode1: transition stateNode1 --> [*] -- direction TB [*] --> stateNode2: transition stateNode2 --> [*]}concurrency --> [*]
Relacionamento de entidade
Sintaxe
erDiagram CAR ||--o{ NAMED-DRIVER : allows PERSON ||--o{ NAMED-DRIVER : is
Relacionamentos
Um para um
erDiagram one ||--|| to-one : relationship
Zero ou um
erDiagram zero-one |o--o| to-zero-one : relationship
Zero ou mais
erDiagram zero-more }o--o{ to-zero-more : relationship
Um ou mais
erDiagram one-more }|--|{ to-one-more : relationship
Atributos
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
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
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
pie showData title Key elements in Product X "Calcium" : 42.96 "Potassium" : 50.05 "Magnesium" : 10.01 "Iron" : 5
Requisitos
Sintaxe
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
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