Skip to content

Commit f81f755

Browse files
committed
Improve Mermaid Chart Data
1 parent ce78c15 commit f81f755

File tree

1 file changed

+89
-2
lines changed
  • client/packages/lowcoder-comps/src/comps/mermaidComp

1 file changed

+89
-2
lines changed

client/packages/lowcoder-comps/src/comps/mermaidComp/index.tsx

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,98 @@ import {
1010

1111
import Mermaid from "./mermaid";
1212

13+
// Collection of example mermaid diagrams that showcase different diagram types
14+
const mermaidExamples = {
15+
flowchart:
16+
`flowchart TD
17+
A[Start] --> B{Is it working?}
18+
B -->|Yes| C[Great!]
19+
B -->|No| D[Debug]
20+
D --> E[Check Documentation]
21+
E --> B
22+
C --> F[Deploy]`,
23+
24+
sequence:
25+
`sequenceDiagram
26+
participant User
27+
participant App
28+
participant API
29+
participant DB
30+
31+
User->>App: Submit Form
32+
App->>API: Send Request
33+
API->>DB: Query Data
34+
DB->>API: Return Result
35+
API->>App: Send Response
36+
App->>User: Show Result`,
37+
38+
classDiagram:
39+
`classDiagram
40+
class User {
41+
+String name
42+
+String email
43+
+authenticate()
44+
+updateProfile()
45+
}
46+
class Product {
47+
+String name
48+
+Number price
49+
+getDetails()
50+
}
51+
class Order {
52+
+Date date
53+
+Number total
54+
+process()
55+
}
56+
User "1" --> "*" Order
57+
Order "*" --> "*" Product`,
58+
59+
gantt:
60+
`gantt
61+
title Project Timeline
62+
dateFormat YYYY-MM-DD
63+
64+
section Planning
65+
Research :done, a1, 2023-01-01, 10d
66+
Requirements :active, a2, after a1, 7d
67+
68+
section Development
69+
Design :a3, after a2, 8d
70+
Implementation :a4, after a3, 14d
71+
Testing :a5, after a4, 7d
72+
73+
section Deployment
74+
Release :milestone, after a5, 0d`,
75+
76+
entityRelationship:
77+
`erDiagram
78+
CUSTOMER }|--o{ ORDER : places
79+
ORDER ||--|{ ORDER_ITEM : contains
80+
CUSTOMER ||--o{ PAYMENT : makes
81+
PRODUCT ||--|{ ORDER_ITEM : "ordered in"`,
82+
83+
journey:
84+
`journey
85+
title User Purchase Journey
86+
section Visit Website
87+
Homepage: 5: User
88+
Product listing: 4: User
89+
Product detail: 3: User
90+
section Purchase
91+
Add to cart: 4: User
92+
Checkout: 3: User, Admin
93+
Payment: 3: User, Admin
94+
section Post-Purchase
95+
Order confirmation: 5: User, Admin
96+
Shipping: 4: Admin
97+
Delivery: 5: User, Admin`
98+
};
99+
100+
// Using the flowchart example as default
13101
const childrenMap = {
14102
code: stringExposingStateControl(
15103
"code",
16-
`graph LR
17-
Start --> Stop`
104+
mermaidExamples.flowchart
18105
),
19106
onEvent: eventHandlerControl([
20107
{

0 commit comments

Comments
 (0)