2.10.0
中文
Skip to content

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]
```
Mermaid

A flowchart.

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]
```

Progressively render a streaming Mermaid fence.

Mermaid API ​

PropDescriptionTypeDefault
childrenChart source codestring-
headerTop bar. Passing VNode is fully customizable; 'null' does not render the default toolbarVNode | nullDefault zoom / copy / download / code switch
classNameRoot class namestring-
classNamesSemantic class names: 'root' / 'header' / 'graph' / 'code'Partial\<Record<'root' | 'header' | 'graph' | 'code', string\>\>-
stylesSemantic styling, key identical to 'classNames'Partial\<Record<..., CSSProperties\>\>-
styleRoot inline styleCSSProperties-
prefixClsOverride class prefixstring-

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).

Render a line chart after the stream finishes.

See the overall steps at Plugin · Mermaid.