Mermaid · GPT-VIS
Fenced code in the language mermaid can be handed over to Mermaid to draw diagrams in the browser. On the server side, the source code is displayed first. Import from @ant-design-x-vue/x-markdown/plugins/Mermaid.
Mermaid
```mermaid graph TD A[Start] --> B[Answer] ```
Here are several Mermaid diagram examples
#### 1. Flowchart (Vertical)
``` mermaid
graph TD
A[Start] --> B{Data Valid?}
B -->|Yes| C[Process Data]
B -->|No| D[Error Handling]
C --> E[Generate Report]
D --> E
E --> F[End]
style A fill:#2ecc71,stroke:#27ae60
style F fill:#e74c3c,stroke:#c0392b
```
#### 2. Sequence Diagram
``` mermaid
sequenceDiagram
participant Client
participant Server
participant Database
Client->>Server: POST /api/data
Server->>Database: INSERT record
Database-->>Server: Success
Server-->>Client: 201 Created
```
#### 3. Quadrant Chart
```mermaid
quadrantChart
title Reach and engagement of campaigns
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 We should expand
quadrant-2 Need to promote
quadrant-3 Re-evaluate
quadrant-4 May be improved
Campaign A: [0.3, 0.6]
Campaign B: [0.45, 0.23]
Campaign C: [0.57, 0.69]
Campaign D: [0.78, 0.34]
Campaign E: [0.40, 0.34]
Campaign F: [0.35, 0.78]
```
Mermaid API
| Prop | Description | Type | Default |
|---|---|---|---|
| children | Chart source code | string | - |
| header | Top bar. Passing VNode is fully customizable; 'null' does not render the default toolbar | VNode | null | Default zoom / copy / download / code switch |
| className | Root class name | string | - |
| classNames | Semantic class names: 'root' / 'header' / 'graph' / 'code' | Partial\<Record<'root' | 'header' | 'graph' | 'code', string\>\> | - |
| styles | Semantic styling, key identical to 'classNames' | Partial\<Record<..., CSSProperties\>\> | - |
| style | Root inline style | CSSProperties | - |
| prefixCls | Override class prefix | string | - |
Toolbar copy comes from 'useLocale('Mermaid')', see Theme and Copywriting.
GPT-VIS
Custom tags can also be mapped to charts. Next, use 'custom-line' together with the GPT-VIS Line adaptation layer in docs (avoid loading into the full G6 package).
See the overall steps at Plugin · Mermaid.