mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 22:39:26 +02:00
Compare commits
134 Commits
usecase_di
...
knsv/mindm
Author | SHA1 | Date | |
---|---|---|---|
![]() |
180dc7bdff | ||
![]() |
cc9581842d | ||
![]() |
d782e4bb17 | ||
![]() |
ba9ad9385b | ||
![]() |
91edfa40f7 | ||
![]() |
c8b00bb929 | ||
![]() |
57eadbf6af | ||
![]() |
a906adce26 | ||
![]() |
a6d26ef6c3 | ||
![]() |
2b3f94eb7d | ||
![]() |
bf3ca9d1ef | ||
![]() |
dd36046e23 | ||
![]() |
1507435e15 | ||
![]() |
e53c17a012 | ||
![]() |
bb2d6973ba | ||
![]() |
9322771b5c | ||
![]() |
2fe3063bf5 | ||
![]() |
4e55a45b1b | ||
![]() |
3d319824a6 | ||
![]() |
aa5d443a46 | ||
![]() |
356da0b4d7 | ||
![]() |
22530a8bdf | ||
![]() |
e6574ef40c | ||
![]() |
c4eb526162 | ||
![]() |
68c01b76bf | ||
![]() |
4d62d59632 | ||
![]() |
5af489d8dd | ||
![]() |
28717e108d | ||
![]() |
688d9b383d | ||
![]() |
074701e316 | ||
![]() |
e68424d748 | ||
![]() |
4b31361506 | ||
![]() |
204a9a338f | ||
![]() |
6a6a39ff33 | ||
![]() |
b296db9a33 | ||
![]() |
01ce84d8ee | ||
![]() |
f48e663d4c | ||
![]() |
a4aa2bd355 | ||
![]() |
b51b9d50c2 | ||
![]() |
165ffefad5 | ||
![]() |
9258b2933b | ||
![]() |
f5445b266e | ||
![]() |
7a1530d911 | ||
![]() |
b61780f735 | ||
![]() |
074f18dfb8 | ||
![]() |
b451c66d7c | ||
![]() |
d7308b0f43 | ||
![]() |
1dd11705d9 | ||
![]() |
2f1860386a | ||
![]() |
f0bca7da55 | ||
![]() |
6fcdf5bfcc | ||
![]() |
e2ce0450c1 | ||
![]() |
29de40478f | ||
![]() |
c95c64139d | ||
![]() |
a7f12f1baa | ||
![]() |
2a8653de2b | ||
![]() |
a92c3bb251 | ||
![]() |
3677abe9e5 | ||
![]() |
95847ad236 | ||
![]() |
e0152fb873 | ||
![]() |
2298b96d8e | ||
![]() |
5db83365b6 | ||
![]() |
341a81a113 | ||
![]() |
8a62b4cace | ||
![]() |
ccafc20917 | ||
![]() |
d5cb4eaa59 | ||
![]() |
425fb7ee33 | ||
![]() |
cd6f8e5a24 | ||
![]() |
a14cd0e2a1 | ||
![]() |
0823e08a54 | ||
![]() |
5cafe241d0 | ||
![]() |
c847817a54 | ||
![]() |
3ab0961bdc | ||
![]() |
0892870b5d | ||
![]() |
500f90a105 | ||
![]() |
14983158a2 | ||
![]() |
3fea9e8759 | ||
![]() |
e5ea2ed0b1 | ||
![]() |
34e7f9704b | ||
![]() |
1176d30668 | ||
![]() |
6728852b7a | ||
![]() |
15e7c890ed | ||
![]() |
0451e343ef | ||
![]() |
a2dbc8e4b3 | ||
![]() |
aea16eaf7e | ||
![]() |
bb7cd70034 | ||
![]() |
35a92efcdc | ||
![]() |
fce7cabb71 | ||
![]() |
38e6dc497a | ||
![]() |
5f0c53c8a7 | ||
![]() |
f9da4433ff | ||
![]() |
fc07f0d8ab | ||
![]() |
ce7a487dfc | ||
![]() |
8c0d12027d | ||
![]() |
1414380181 | ||
![]() |
6686ee9253 | ||
![]() |
7f109c7b94 | ||
![]() |
b9c3375be3 | ||
![]() |
4254bdd473 | ||
![]() |
4012cbf013 | ||
![]() |
814b68b4a9 | ||
![]() |
bfa0eefa32 | ||
![]() |
579c22cf5d | ||
![]() |
33e08daf17 | ||
![]() |
24257de8a6 | ||
![]() |
42ac1848dd | ||
![]() |
3920ad442d | ||
![]() |
53d27b771d | ||
![]() |
2c0931da46 | ||
![]() |
8224a81ab6 | ||
![]() |
98442294ed | ||
![]() |
a3d164fde8 | ||
![]() |
9dc987b28b | ||
![]() |
72c0d9df26 | ||
![]() |
cfbce54638 | ||
![]() |
6979aa1013 | ||
![]() |
ea60525988 | ||
![]() |
9da6fb39ae | ||
![]() |
83b9a17277 | ||
![]() |
f0445b74d1 | ||
![]() |
ba52eef257 | ||
![]() |
c13ce2a5c0 | ||
![]() |
d2463f41b5 | ||
![]() |
eadb343292 | ||
![]() |
e7208622f7 | ||
![]() |
fbae611406 | ||
![]() |
34027bc589 | ||
![]() |
f2eef37599 | ||
![]() |
6cc192680a | ||
![]() |
3dd6107e76 | ||
![]() |
1e3ea13323 | ||
![]() |
4c8c48cde9 | ||
![]() |
c8e50276e8 | ||
![]() |
1e6419a63f |
@@ -33,6 +33,11 @@ export const packageOptions = {
|
|||||||
packageName: 'mermaid-layout-elk',
|
packageName: 'mermaid-layout-elk',
|
||||||
file: 'layouts.ts',
|
file: 'layouts.ts',
|
||||||
},
|
},
|
||||||
|
'mermaid-layout-tidy-tree': {
|
||||||
|
name: 'mermaid-layout-tidy-tree',
|
||||||
|
packageName: 'mermaid-layout-tidy-tree',
|
||||||
|
file: 'index.ts',
|
||||||
|
},
|
||||||
examples: {
|
examples: {
|
||||||
name: 'mermaid-examples',
|
name: 'mermaid-examples',
|
||||||
packageName: 'examples',
|
packageName: 'examples',
|
||||||
|
5
.changeset/chatty-lemons-stick.md
Normal file
5
.changeset/chatty-lemons-stick.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: Remove the "-beta" suffix from the XYChart, Block, Sankey diagrams to reflect their stable status
|
5
.changeset/cold-sites-accept.md
Normal file
5
.changeset/cold-sites-accept.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Position the edge label in state diagram correctly relative to the edge
|
5
.changeset/empty-clouds-cry.md
Normal file
5
.changeset/empty-clouds-cry.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Apply correct dateFormat in Gantt chart to show only day when specified
|
5
.changeset/fuzzy-pears-cough.md
Normal file
5
.changeset/fuzzy-pears-cough.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: handle exclude dates properly in Gantt charts when using dateFormat: 'YYYY-MM-DD HH:mm:ss'
|
5
.changeset/gold-spiders-join.md
Normal file
5
.changeset/gold-spiders-join.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: fixed connection gaps in flowchart for roundedRect, stadium and diamond shape
|
7
.changeset/hungry-guests-drive.md
Normal file
7
.changeset/hungry-guests-drive.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
'mermaid': minor
|
||||||
|
'@mermaid-js/layout-tidy-tree': minor
|
||||||
|
'@mermaid-js/layout-elk': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: Update mindmap rendering to support multiple layouts, improved edge intersections, and new shapes
|
5
.changeset/red-zebras-happen.md
Normal file
5
.changeset/red-zebras-happen.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Allow equals sign in sequenceDiagram labels
|
9
.changeset/seven-papayas-film.md
Normal file
9
.changeset/seven-papayas-film.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add validation for negative values in pie charts:
|
||||||
|
|
||||||
|
Prevents crashes during parsing by validating values post-parsing.
|
||||||
|
|
||||||
|
Provides clearer, user-friendly error messages for invalid negative inputs.
|
5
.changeset/six-planets-rescue.md
Normal file
5
.changeset/six-planets-rescue.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: node border style for handdrawn shapes
|
5
.changeset/strong-dryers-pay.md
Normal file
5
.changeset/strong-dryers-pay.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: correctly render non-directional lines for '---' in block diagrams
|
@@ -143,7 +143,6 @@ typeof
|
|||||||
typestr
|
typestr
|
||||||
unshift
|
unshift
|
||||||
urlsafe
|
urlsafe
|
||||||
usecase
|
|
||||||
verifymethod
|
verifymethod
|
||||||
VERIFYMTHD
|
VERIFYMTHD
|
||||||
WARN_DOCSDIR_DOESNT_MATCH
|
WARN_DOCSDIR_DOESNT_MATCH
|
||||||
|
2
.github/workflows/e2e-timings.yml
vendored
2
.github/workflows/e2e-timings.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
|||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Commit and create pull request
|
- name: Commit and create pull request
|
||||||
uses: peter-evans/create-pull-request@07cbaebb4bfc9c5d7db426ea5a5f585df29dd0a0
|
uses: peter-evans/create-pull-request@1310d7dab503600742045e6fd4b84dda64352858
|
||||||
with:
|
with:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
cypress/timings.json
|
cypress/timings.json
|
||||||
|
2
.github/workflows/validate-lockfile.yml
vendored
2
.github/workflows/validate-lockfile.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
|||||||
|
|
||||||
# 2) No unwanted vitepress paths
|
# 2) No unwanted vitepress paths
|
||||||
if grep -qF 'packages/mermaid/src/vitepress' pnpm-lock.yaml; then
|
if grep -qF 'packages/mermaid/src/vitepress' pnpm-lock.yaml; then
|
||||||
issues+=("• Disallowed path 'packages/mermaid/src/vitepress' present. Run `rm -rf packages/mermaid/src/vitepress && pnpm install` to regenerate.")
|
issues+=("• Disallowed path 'packages/mermaid/src/vitepress' present. Run \`rm -rf packages/mermaid/src/vitepress && pnpm install\` to regenerate.")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3) Lockfile only changes when package.json changes
|
# 3) Lockfile only changes when package.json changes
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ node_modules/
|
|||||||
coverage/
|
coverage/
|
||||||
.idea/
|
.idea/
|
||||||
.pnpm-store/
|
.pnpm-store/
|
||||||
|
.instructions/
|
||||||
|
|
||||||
dist
|
dist
|
||||||
v8-compile-cache-0
|
v8-compile-cache-0
|
||||||
|
@@ -16,7 +16,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL2: should handle columns statement in sub-blocks', () => {
|
it('BL2: should handle columns statement in sub-blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
id1["Hello"]
|
id1["Hello"]
|
||||||
block
|
block
|
||||||
columns 3
|
columns 3
|
||||||
@@ -32,7 +32,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL3: should align block widths and handle columns statement in sub-blocks', () => {
|
it('BL3: should align block widths and handle columns statement in sub-blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
block
|
block
|
||||||
columns 1
|
columns 1
|
||||||
id1
|
id1
|
||||||
@@ -48,7 +48,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL4: should align block widths and handle columns statements in deeper sub-blocks then 1 level', () => {
|
it('BL4: should align block widths and handle columns statements in deeper sub-blocks then 1 level', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 1
|
columns 1
|
||||||
block
|
block
|
||||||
columns 1
|
columns 1
|
||||||
@@ -68,7 +68,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL5: should align block widths and handle columns statements in deeper sub-blocks then 1 level (alt)', () => {
|
it('BL5: should align block widths and handle columns statements in deeper sub-blocks then 1 level (alt)', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 1
|
columns 1
|
||||||
block
|
block
|
||||||
id1
|
id1
|
||||||
@@ -87,7 +87,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL6: should handle block arrows and spece statements', () => {
|
it('BL6: should handle block arrows and spece statements', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
space:3
|
space:3
|
||||||
ida idb idc
|
ida idb idc
|
||||||
@@ -106,7 +106,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL7: should handle different types of edges', () => {
|
it('BL7: should handle different types of edges', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
A space:5
|
A space:5
|
||||||
A --o B
|
A --o B
|
||||||
@@ -119,7 +119,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL8: should handle sub-blocks without columns statements', () => {
|
it('BL8: should handle sub-blocks without columns statements', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 2
|
columns 2
|
||||||
C A B
|
C A B
|
||||||
block
|
block
|
||||||
@@ -133,7 +133,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL9: should handle edges from blocks in sub blocks to other blocks', () => {
|
it('BL9: should handle edges from blocks in sub blocks to other blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
B space
|
B space
|
||||||
block
|
block
|
||||||
@@ -147,7 +147,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL10: should handle edges from composite blocks', () => {
|
it('BL10: should handle edges from composite blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
B space
|
B space
|
||||||
block BL
|
block BL
|
||||||
@@ -161,7 +161,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL11: should handle edges to composite blocks', () => {
|
it('BL11: should handle edges to composite blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
B space
|
B space
|
||||||
block BL
|
block BL
|
||||||
@@ -175,7 +175,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL12: edges should handle labels', () => {
|
it('BL12: edges should handle labels', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A
|
A
|
||||||
space
|
space
|
||||||
A -- "apa" --> E
|
A -- "apa" --> E
|
||||||
@@ -186,7 +186,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL13: should handle block arrows in different directions', () => {
|
it('BL13: should handle block arrows in different directions', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
space blockArrowId1<["down"]>(down) space
|
space blockArrowId1<["down"]>(down) space
|
||||||
blockArrowId2<["right"]>(right) blockArrowId3<["Sync"]>(x, y) blockArrowId4<["left"]>(left)
|
blockArrowId2<["right"]>(right) blockArrowId3<["Sync"]>(x, y) blockArrowId4<["left"]>(left)
|
||||||
@@ -199,7 +199,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL14: should style statements and class statements', () => {
|
it('BL14: should style statements and class statements', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
classDef blue fill:#66f,stroke:#333,stroke-width:2px;
|
classDef blue fill:#66f,stroke:#333,stroke-width:2px;
|
||||||
@@ -212,7 +212,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL15: width alignment - D and E should share available space', () => {
|
it('BL15: width alignment - D and E should share available space', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
block
|
block
|
||||||
D
|
D
|
||||||
E
|
E
|
||||||
@@ -225,7 +225,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL16: width alignment - C should be as wide as the composite block', () => {
|
it('BL16: width alignment - C should be as wide as the composite block', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
block
|
block
|
||||||
A("This is the text")
|
A("This is the text")
|
||||||
B
|
B
|
||||||
@@ -238,7 +238,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL17: width alignment - blocks should be equal in width', () => {
|
it('BL17: width alignment - blocks should be equal in width', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A("This is the text")
|
A("This is the text")
|
||||||
B
|
B
|
||||||
C
|
C
|
||||||
@@ -249,7 +249,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL18: block types 1 - square, rounded and circle', () => {
|
it('BL18: block types 1 - square, rounded and circle', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A["square"]
|
A["square"]
|
||||||
B("rounded")
|
B("rounded")
|
||||||
C(("circle"))
|
C(("circle"))
|
||||||
@@ -260,7 +260,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL19: block types 2 - odd, diamond and hexagon', () => {
|
it('BL19: block types 2 - odd, diamond and hexagon', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A>"rect_left_inv_arrow"]
|
A>"rect_left_inv_arrow"]
|
||||||
B{"diamond"}
|
B{"diamond"}
|
||||||
C{{"hexagon"}}
|
C{{"hexagon"}}
|
||||||
@@ -271,7 +271,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL20: block types 3 - stadium', () => {
|
it('BL20: block types 3 - stadium', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A(["stadium"])
|
A(["stadium"])
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
@@ -280,7 +280,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL21: block types 4 - lean right, lean left, trapezoid and inv trapezoid', () => {
|
it('BL21: block types 4 - lean right, lean left, trapezoid and inv trapezoid', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A[/"lean right"/]
|
A[/"lean right"/]
|
||||||
B[\"lean left"\]
|
B[\"lean left"\]
|
||||||
C[/"trapezoid"\]
|
C[/"trapezoid"\]
|
||||||
@@ -292,7 +292,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL22: block types 1 - square, rounded and circle', () => {
|
it('BL22: block types 1 - square, rounded and circle', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A["square"]
|
A["square"]
|
||||||
B("rounded")
|
B("rounded")
|
||||||
C(("circle"))
|
C(("circle"))
|
||||||
@@ -303,7 +303,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL23: sizing - it should be possible to make a block wider', () => {
|
it('BL23: sizing - it should be possible to make a block wider', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
A("rounded"):2
|
A("rounded"):2
|
||||||
B:2
|
B:2
|
||||||
C
|
C
|
||||||
@@ -314,7 +314,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL24: sizing - it should be possible to make a composite block wider', () => {
|
it('BL24: sizing - it should be possible to make a composite block wider', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
block:2
|
block:2
|
||||||
A
|
A
|
||||||
end
|
end
|
||||||
@@ -326,7 +326,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL25: block in the middle with space on each side', () => {
|
it('BL25: block in the middle with space on each side', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
space
|
space
|
||||||
middle["In the middle"]
|
middle["In the middle"]
|
||||||
@@ -337,7 +337,7 @@ describe('Block diagram', () => {
|
|||||||
});
|
});
|
||||||
it('BL26: space and an edge', () => {
|
it('BL26: space and an edge', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 5
|
columns 5
|
||||||
A space B
|
A space B
|
||||||
A --x B
|
A --x B
|
||||||
@@ -347,7 +347,7 @@ describe('Block diagram', () => {
|
|||||||
});
|
});
|
||||||
it('BL27: block sizes for regular blocks', () => {
|
it('BL27: block sizes for regular blocks', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
a["A wide one"] b:2 c:2 d
|
a["A wide one"] b:2 c:2 d
|
||||||
`,
|
`,
|
||||||
@@ -356,7 +356,7 @@ describe('Block diagram', () => {
|
|||||||
});
|
});
|
||||||
it('BL28: composite block with a set width - f should use the available space', () => {
|
it('BL28: composite block with a set width - f should use the available space', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
a:3
|
a:3
|
||||||
block:e:3
|
block:e:3
|
||||||
@@ -370,7 +370,7 @@ describe('Block diagram', () => {
|
|||||||
|
|
||||||
it('BL29: composite block with a set width - f and g should split the available space', () => {
|
it('BL29: composite block with a set width - f and g should split the available space', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`block-beta
|
`block
|
||||||
columns 3
|
columns 3
|
||||||
a:3
|
a:3
|
||||||
block:e:3
|
block:e:3
|
||||||
@@ -393,6 +393,17 @@ describe('Block diagram', () => {
|
|||||||
overflow:3
|
overflow:3
|
||||||
short:1
|
short:1
|
||||||
also_overflow:2
|
also_overflow:2
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('BL31: edge without arrow syntax should render with no arrowheads', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`block-beta
|
||||||
|
a
|
||||||
|
b
|
||||||
|
a --- b
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
@@ -1113,6 +1113,37 @@ end
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Flowchart Node Shape Rendering', () => {
|
||||||
|
it('should render a stadium-shaped node', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`flowchart TB
|
||||||
|
A(["Start"]) --> n1["Untitled Node"]
|
||||||
|
A --> n2["Untitled Node"]
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render a diamond-shaped node using shape config', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`flowchart BT
|
||||||
|
n2["Untitled Node"] --> n1["Diamond"]
|
||||||
|
n1@{ shape: diam}
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render a rounded rectangle and a normal rectangle', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`flowchart BT
|
||||||
|
n2["Untitled Node"] --> n1["Rounded Rectangle"]
|
||||||
|
n3["Untitled Node"] --> n1
|
||||||
|
n1@{ shape: rounded}
|
||||||
|
n3@{ shape: rect}
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('6617: Per Link Curve Styling using edge Ids', () => {
|
it('6617: Per Link Curve Styling using edge Ids', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
|
@@ -565,6 +565,18 @@ describe('Gantt diagram', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render only the day when using dateFormat D', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title Test
|
||||||
|
dateFormat D
|
||||||
|
A :a, 1, 1d
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: fix it
|
// TODO: fix it
|
||||||
//
|
//
|
||||||
// This test is skipped deliberately
|
// This test is skipped deliberately
|
||||||
@@ -647,6 +659,49 @@ describe('Gantt diagram', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render a gantt diagram excluding a specific date in YYYY-MM-DD HH:mm:ss format', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
dateFormat YYYY-MM-DD HH:mm:ss
|
||||||
|
excludes 2025-07-07
|
||||||
|
section Section
|
||||||
|
A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30
|
||||||
|
Another task:after a1, 20h
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render a gantt diagram excluding saturday and sunday in YYYY-MM-DD HH:mm:ss format', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
dateFormat YYYY-MM-DD HH:mm:ss
|
||||||
|
excludes weekends
|
||||||
|
weekend saturday
|
||||||
|
section Section
|
||||||
|
A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30
|
||||||
|
Another task:after a1, 20h
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render a gantt diagram excluding friday and saturday in YYYY-MM-DD HH:mm:ss format', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
dateFormat YYYY-MM-DD HH:mm:ss
|
||||||
|
excludes weekends
|
||||||
|
weekend friday
|
||||||
|
section Section
|
||||||
|
A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30
|
||||||
|
Another task:after a1, 20h
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("should render when there's a semicolon in the title", () => {
|
it("should render when there's a semicolon in the title", () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
|
@@ -159,12 +159,10 @@ root
|
|||||||
});
|
});
|
||||||
it('square shape', () => {
|
it('square shape', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
|
||||||
root[
|
root[
|
||||||
The root
|
The root
|
||||||
]
|
]`,
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
@@ -172,12 +170,10 @@ mindmap
|
|||||||
});
|
});
|
||||||
it('rounded rect shape', () => {
|
it('rounded rect shape', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
|
||||||
root((
|
root((
|
||||||
The root
|
The root
|
||||||
))
|
))`,
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
@@ -185,12 +181,10 @@ mindmap
|
|||||||
});
|
});
|
||||||
it('circle shape', () => {
|
it('circle shape', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
|
||||||
root(
|
root(
|
||||||
The root
|
The root
|
||||||
)
|
)`,
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
@@ -198,10 +192,8 @@ mindmap
|
|||||||
});
|
});
|
||||||
it('default shape', () => {
|
it('default shape', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
The root`,
|
||||||
The root
|
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
@@ -209,12 +201,10 @@ mindmap
|
|||||||
});
|
});
|
||||||
it('adding children', () => {
|
it('adding children', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
|
||||||
The root
|
The root
|
||||||
child1
|
child1
|
||||||
child2
|
child2`,
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
@@ -222,13 +212,11 @@ mindmap
|
|||||||
});
|
});
|
||||||
it('adding grand children', () => {
|
it('adding grand children', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`mindmap
|
||||||
mindmap
|
|
||||||
The root
|
The root
|
||||||
child1
|
child1
|
||||||
child2
|
child2
|
||||||
child3
|
child3`,
|
||||||
`,
|
|
||||||
{},
|
{},
|
||||||
undefined,
|
undefined,
|
||||||
shouldHaveRoot
|
shouldHaveRoot
|
||||||
|
@@ -82,4 +82,13 @@ describe('pie chart', () => {
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should render pie slices only for non-zero values but shows all legends', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
` pie title Pets adopted by volunteers
|
||||||
|
"Dogs" : 386
|
||||||
|
"Cats" : 85
|
||||||
|
"Rats" : 1
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -15,7 +15,7 @@ describe('Sankey Diagram', () => {
|
|||||||
describe('when given a linkColor', function () {
|
describe('when given a linkColor', function () {
|
||||||
this.beforeAll(() => {
|
this.beforeAll(() => {
|
||||||
cy.wrap(
|
cy.wrap(
|
||||||
`sankey-beta
|
`sankey
|
||||||
a,b,10
|
a,b,10
|
||||||
`
|
`
|
||||||
).as('graph');
|
).as('graph');
|
||||||
@@ -62,7 +62,7 @@ describe('Sankey Diagram', () => {
|
|||||||
this.beforeAll(() => {
|
this.beforeAll(() => {
|
||||||
cy.wrap(
|
cy.wrap(
|
||||||
`
|
`
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
a,b,8
|
a,b,8
|
||||||
b,c,8
|
b,c,8
|
||||||
|
@@ -602,6 +602,231 @@ State1 --> [*]
|
|||||||
--
|
--
|
||||||
55
|
55
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render edge labels correctly', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`---
|
||||||
|
title: On The Way To Something Something DarkSide
|
||||||
|
config:
|
||||||
|
look: default
|
||||||
|
theme: default
|
||||||
|
---
|
||||||
|
|
||||||
|
stateDiagram-v2
|
||||||
|
|
||||||
|
state State1_____________
|
||||||
|
{
|
||||||
|
c0
|
||||||
|
}
|
||||||
|
|
||||||
|
state State2_____________
|
||||||
|
{
|
||||||
|
c1
|
||||||
|
}
|
||||||
|
|
||||||
|
state State3_____________
|
||||||
|
{
|
||||||
|
c7
|
||||||
|
}
|
||||||
|
|
||||||
|
state State4_____________
|
||||||
|
{
|
||||||
|
c2
|
||||||
|
}
|
||||||
|
|
||||||
|
state State5_____________
|
||||||
|
{
|
||||||
|
c3
|
||||||
|
}
|
||||||
|
|
||||||
|
state State6_____________
|
||||||
|
{
|
||||||
|
c4
|
||||||
|
}
|
||||||
|
|
||||||
|
state State7_____________
|
||||||
|
{
|
||||||
|
c5
|
||||||
|
}
|
||||||
|
|
||||||
|
state State8_____________
|
||||||
|
{
|
||||||
|
c6
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[*] --> State1_____________
|
||||||
|
State1_____________ --> State2_____________ : Transition1_____
|
||||||
|
State2_____________ --> State4_____________ : Transition2_____
|
||||||
|
State2_____________ --> State3_____________ : Transition3_____
|
||||||
|
State3_____________ --> State2_____________
|
||||||
|
State4_____________ --> State2_____________ : Transition5_____
|
||||||
|
State4_____________ --> State5_____________ : Transition6_____
|
||||||
|
State5_____________ --> State6_____________ : Transition7_____
|
||||||
|
State6_____________ --> State4_____________ : Transition8_____
|
||||||
|
State2_____________ --> State7_____________ : Transition4_____
|
||||||
|
State4_____________ --> State7_____________ : Transition4_____
|
||||||
|
State5_____________ --> State7_____________ : Transition4_____
|
||||||
|
State6_____________ --> State7_____________ : Transition4_____
|
||||||
|
State7_____________ --> State1_____________ : Transition9_____
|
||||||
|
State5_____________ --> State8_____________ : Transition10____
|
||||||
|
State8_____________ --> State5_____________ : Transition11____
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render edge labels correctly with multiple transitions', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`---
|
||||||
|
title: Multiple Transitions
|
||||||
|
config:
|
||||||
|
look: default
|
||||||
|
theme: default
|
||||||
|
---
|
||||||
|
|
||||||
|
stateDiagram-v2
|
||||||
|
|
||||||
|
state State1_____________
|
||||||
|
{
|
||||||
|
c0
|
||||||
|
}
|
||||||
|
|
||||||
|
state State2_____________
|
||||||
|
{
|
||||||
|
c1
|
||||||
|
}
|
||||||
|
|
||||||
|
state State3_____________
|
||||||
|
{
|
||||||
|
c7
|
||||||
|
}
|
||||||
|
|
||||||
|
state State4_____________
|
||||||
|
{
|
||||||
|
c2
|
||||||
|
}
|
||||||
|
|
||||||
|
state State5_____________
|
||||||
|
{
|
||||||
|
c3
|
||||||
|
}
|
||||||
|
|
||||||
|
state State6_____________
|
||||||
|
{
|
||||||
|
c4
|
||||||
|
}
|
||||||
|
|
||||||
|
state State7_____________
|
||||||
|
{
|
||||||
|
c5
|
||||||
|
}
|
||||||
|
|
||||||
|
state State8_____________
|
||||||
|
{
|
||||||
|
c6
|
||||||
|
}
|
||||||
|
|
||||||
|
state State9_____________
|
||||||
|
{
|
||||||
|
c9
|
||||||
|
}
|
||||||
|
|
||||||
|
[*] --> State1_____________
|
||||||
|
State1_____________ --> State2_____________ : Transition1_____
|
||||||
|
State2_____________ --> State4_____________ : Transition2_____
|
||||||
|
State2_____________ --> State3_____________ : Transition3_____
|
||||||
|
State3_____________ --> State2_____________
|
||||||
|
State4_____________ --> State2_____________ : Transition5_____
|
||||||
|
State4_____________ --> State5_____________ : Transition6_____
|
||||||
|
State5_____________ --> State6_____________ : Transition7_____
|
||||||
|
State6_____________ --> State4_____________ : Transition8_____
|
||||||
|
State2_____________ --> State7_____________ : Transition4_____
|
||||||
|
State4_____________ --> State7_____________ : Transition4_____
|
||||||
|
State5_____________ --> State7_____________ : Transition4_____
|
||||||
|
State6_____________ --> State7_____________ : Transition4_____
|
||||||
|
State7_____________ --> State1_____________ : Transition9_____
|
||||||
|
State5_____________ --> State8_____________ : Transition10____
|
||||||
|
State8_____________ --> State5_____________ : Transition11____
|
||||||
|
State9_____________ --> State8_____________ : Transition12____
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render edge labels correctly with multiple states', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`---
|
||||||
|
title: Multiple States
|
||||||
|
config:
|
||||||
|
look: default
|
||||||
|
theme: default
|
||||||
|
---
|
||||||
|
|
||||||
|
stateDiagram-v2
|
||||||
|
|
||||||
|
state State1_____________
|
||||||
|
{
|
||||||
|
c0
|
||||||
|
}
|
||||||
|
|
||||||
|
state State2_____________
|
||||||
|
{
|
||||||
|
c1
|
||||||
|
}
|
||||||
|
|
||||||
|
state State3_____________
|
||||||
|
{
|
||||||
|
c7
|
||||||
|
}
|
||||||
|
|
||||||
|
state State4_____________
|
||||||
|
{
|
||||||
|
c2
|
||||||
|
}
|
||||||
|
|
||||||
|
state State5_____________
|
||||||
|
{
|
||||||
|
c3
|
||||||
|
}
|
||||||
|
|
||||||
|
state State6_____________
|
||||||
|
{
|
||||||
|
c4
|
||||||
|
}
|
||||||
|
|
||||||
|
state State7_____________
|
||||||
|
{
|
||||||
|
c5
|
||||||
|
}
|
||||||
|
|
||||||
|
state State8_____________
|
||||||
|
{
|
||||||
|
c6
|
||||||
|
}
|
||||||
|
|
||||||
|
state State9_____________
|
||||||
|
{
|
||||||
|
c9
|
||||||
|
}
|
||||||
|
|
||||||
|
state State10_____________
|
||||||
|
{
|
||||||
|
c10
|
||||||
|
}
|
||||||
|
|
||||||
|
[*] --> State1_____________
|
||||||
|
State1_____________ --> State2_____________ : Transition1_____
|
||||||
|
State2_____________ --> State3_____________ : Transition2_____
|
||||||
|
State3_____________ --> State4_____________ : Transition3_____
|
||||||
|
State4_____________ --> State5_____________ : Transition4_____
|
||||||
|
State5_____________ --> State6_____________ : Transition5_____
|
||||||
|
State6_____________ --> State7_____________ : Transition6_____
|
||||||
|
State7_____________ --> State8_____________ : Transition7_____
|
||||||
|
State8_____________ --> State9_____________ : Transition8_____
|
||||||
|
State9_____________ --> State10_____________ : Transition9_____
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('XY Chart', () => {
|
describe('XY Chart', () => {
|
||||||
it('should render the simplest possible chart', () => {
|
it('should render the simplest possible xy-beta chart', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart-beta
|
||||||
@@ -10,10 +10,19 @@ describe('XY Chart', () => {
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should render the simplest possible xy chart', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
xychart
|
||||||
|
line [10, 30, 20]
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
it('Should render a complete chart', () => {
|
it('Should render a complete chart', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -26,7 +35,7 @@ describe('XY Chart', () => {
|
|||||||
it('Should render a chart without title', () => {
|
it('Should render a chart without title', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -38,7 +47,7 @@ describe('XY Chart', () => {
|
|||||||
it('y-axis title not required', () => {
|
it('y-axis title not required', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis 4000 --> 11000
|
y-axis 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -50,7 +59,7 @@ describe('XY Chart', () => {
|
|||||||
it('Should render a chart without y-axis with different range', () => {
|
it('Should render a chart without y-axis with different range', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
|
||||||
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
|
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
|
||||||
@@ -61,7 +70,7 @@ describe('XY Chart', () => {
|
|||||||
it('x axis title not required', () => {
|
it('x axis title not required', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
|
||||||
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
|
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
|
||||||
@@ -72,7 +81,7 @@ describe('XY Chart', () => {
|
|||||||
it('Multiple plots can be rendered', () => {
|
it('Multiple plots can be rendered', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
line [23, 46, 77, 34]
|
line [23, 46, 77, 34]
|
||||||
line [45, 32, 33, 12]
|
line [45, 32, 33, 12]
|
||||||
bar [87, 54, 99, 85]
|
bar [87, 54, 99, 85]
|
||||||
@@ -86,7 +95,7 @@ describe('XY Chart', () => {
|
|||||||
it('Decimals and negative numbers are supported', () => {
|
it('Decimals and negative numbers are supported', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
y-axis -2.4 --> 3.5
|
y-axis -2.4 --> 3.5
|
||||||
line [+1.3, .6, 2.4, -.34]
|
line [+1.3, .6, 2.4, -.34]
|
||||||
`,
|
`,
|
||||||
@@ -104,7 +113,7 @@ describe('XY Chart', () => {
|
|||||||
height: 20
|
height: 20
|
||||||
plotReservedSpacePercent: 100
|
plotReservedSpacePercent: 100
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
line [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
line [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
@@ -130,7 +139,7 @@ describe('XY Chart', () => {
|
|||||||
showTick: false
|
showTick: false
|
||||||
showAxisLine: false
|
showAxisLine: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
bar [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
bar [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
@@ -140,7 +149,7 @@ describe('XY Chart', () => {
|
|||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
%%{init: {"xyChart": {"width": 1000, "height": 600, "titlePadding": 5, "titleFontSize": 10, "xAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "yAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "plotBorderWidth": 5, "chartOrientation": "horizontal", "plotReservedSpacePercent": 60 }}}%%
|
%%{init: {"xyChart": {"width": 1000, "height": 600, "titlePadding": 5, "titleFontSize": 10, "xAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "yAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "plotBorderWidth": 5, "chartOrientation": "horizontal", "plotReservedSpacePercent": 60 }}}%%
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -181,7 +190,7 @@ describe('XY Chart', () => {
|
|||||||
plotReservedSpacePercent: 60
|
plotReservedSpacePercent: 60
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -202,7 +211,7 @@ describe('XY Chart', () => {
|
|||||||
yAxis:
|
yAxis:
|
||||||
showTitle: false
|
showTitle: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -223,7 +232,7 @@ describe('XY Chart', () => {
|
|||||||
yAxis:
|
yAxis:
|
||||||
showLabel: false
|
showLabel: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -244,7 +253,7 @@ describe('XY Chart', () => {
|
|||||||
yAxis:
|
yAxis:
|
||||||
showTick: false
|
showTick: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -265,7 +274,7 @@ describe('XY Chart', () => {
|
|||||||
yAxis:
|
yAxis:
|
||||||
showAxisLine: false
|
showAxisLine: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -294,7 +303,7 @@ describe('XY Chart', () => {
|
|||||||
xAxisLineColor: "#87ceeb"
|
xAxisLineColor: "#87ceeb"
|
||||||
plotColorPalette: "#008000, #faba63"
|
plotColorPalette: "#008000, #faba63"
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -307,7 +316,7 @@ describe('XY Chart', () => {
|
|||||||
it('should use the correct distances between data points', () => {
|
it('should use the correct distances between data points', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
x-axis 0 --> 2
|
x-axis 0 --> 2
|
||||||
line [0, 1, 0, 1]
|
line [0, 1, 0, 1]
|
||||||
bar [1, 0, 1, 0]
|
bar [1, 0, 1, 0]
|
||||||
@@ -325,7 +334,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -344,7 +353,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -357,7 +366,7 @@ describe('XY Chart', () => {
|
|||||||
it('should render vertical bar chart without labels by default', () => {
|
it('should render vertical bar chart without labels by default', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -375,7 +384,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -393,7 +402,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Multiple Bar Plots"
|
title "Multiple Bar Plots"
|
||||||
x-axis Categories [A, B, C]
|
x-axis Categories [A, B, C]
|
||||||
y-axis "Values" 0 --> 100
|
y-axis "Values" 0 --> 100
|
||||||
@@ -412,7 +421,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Multiple Bar Plots"
|
title "Multiple Bar Plots"
|
||||||
x-axis Categories [A, B, C]
|
x-axis Categories [A, B, C]
|
||||||
y-axis "Values" 0 --> 100
|
y-axis "Values" 0 --> 100
|
||||||
@@ -430,7 +439,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Single Bar Chart"
|
title "Single Bar Chart"
|
||||||
x-axis Categories [A]
|
x-axis Categories [A]
|
||||||
y-axis "Value" 0 --> 100
|
y-axis "Value" 0 --> 100
|
||||||
@@ -449,7 +458,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Single Bar Chart"
|
title "Single Bar Chart"
|
||||||
x-axis Categories [A]
|
x-axis Categories [A]
|
||||||
y-axis "Value" 0 --> 100
|
y-axis "Value" 0 --> 100
|
||||||
@@ -467,7 +476,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Decimal and Negative Values"
|
title "Decimal and Negative Values"
|
||||||
x-axis Categories [A, B, C]
|
x-axis Categories [A, B, C]
|
||||||
y-axis -10 --> 10
|
y-axis -10 --> 10
|
||||||
@@ -486,7 +495,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Decimal and Negative Values"
|
title "Decimal and Negative Values"
|
||||||
x-axis Categories [A, B, C]
|
x-axis Categories [A, B, C]
|
||||||
y-axis -10 --> 10
|
y-axis -10 --> 10
|
||||||
@@ -504,7 +513,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan,b,c]
|
x-axis Months [jan,b,c]
|
||||||
y-axis "Revenue (in $)" 4000 --> 12000
|
y-axis "Revenue (in $)" 4000 --> 12000
|
||||||
@@ -561,7 +570,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan,b,c]
|
x-axis Months [jan,b,c]
|
||||||
y-axis "Revenue (in $)" 4000 --> 12000
|
y-axis "Revenue (in $)" 4000 --> 12000
|
||||||
@@ -615,7 +624,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]
|
x-axis Months [jan,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]
|
||||||
y-axis "Revenue (in $)" 4000 --> 12000
|
y-axis "Revenue (in $)" 4000 --> 12000
|
||||||
@@ -672,7 +681,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]
|
x-axis Months [jan,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s]
|
||||||
y-axis "Revenue (in $)" 4000 --> 12000
|
y-axis "Revenue (in $)" 4000 --> 12000
|
||||||
@@ -726,7 +735,7 @@ describe('XY Chart', () => {
|
|||||||
xyChart:
|
xyChart:
|
||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan]
|
x-axis Months [jan]
|
||||||
y-axis "Revenue (in $)" 3000 --> 12000
|
y-axis "Revenue (in $)" 3000 --> 12000
|
||||||
@@ -783,7 +792,7 @@ describe('XY Chart', () => {
|
|||||||
showDataLabel: true
|
showDataLabel: true
|
||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan]
|
x-axis Months [jan]
|
||||||
y-axis "Revenue (in $)" 3000 --> 12000
|
y-axis "Revenue (in $)" 3000 --> 12000
|
||||||
|
35
cypress/platform/darshan.html
Normal file
35
cypress/platform/darshan.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<title>Mermaid Quick Test Page</title>
|
||||||
|
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
|
||||||
|
<style>
|
||||||
|
div.mermaid {
|
||||||
|
font-family: 'Courier New', Courier, monospace !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Pie chart demos</h1>
|
||||||
|
<pre class="mermaid">
|
||||||
|
pie title Default text position: Animal adoption
|
||||||
|
accTitle: simple pie char demo
|
||||||
|
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
||||||
|
"dogs" : -60.67
|
||||||
|
"rats" : 40.12
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from '/mermaid.esm.mjs';
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'forest',
|
||||||
|
logLevel: 3,
|
||||||
|
securityLevel: 'loose',
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -130,6 +130,76 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
Pen and paper
|
||||||
|
Mermaid
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
</pre
|
||||||
|
>
|
||||||
|
<pre id="diagram4" class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
B
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
D
|
||||||
|
apa5[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
treemap
|
treemap
|
||||||
"Section 1"
|
"Section 1"
|
||||||
@@ -175,8 +245,145 @@ treemap
|
|||||||
"Item B2": 25
|
"Item B2": 25
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram4" class="mermaid2">
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
flowchart TB
|
||||||
|
A --> n0["1"]
|
||||||
|
A --> n1["2"]
|
||||||
|
A --> n2["3"]
|
||||||
|
A --> n3["4"] --> Q & R & S & T
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
flowchart TB
|
||||||
|
A --> n0["1"]
|
||||||
|
A --> n1["2"]
|
||||||
|
A --> n2["3"]
|
||||||
|
A --> n3["4"] --> Q & R & S & T
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
Pen and paper
|
||||||
|
Mermaid
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
Pen and paper
|
||||||
|
Mermaid
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
Pen and paper
|
||||||
|
Mermaid
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
flowchart LR
|
flowchart LR
|
||||||
AB["apa@apa@"] --> B(("`apa@apa`"))
|
root{mindmap} --- Origins --- Europe
|
||||||
|
Origins --> Asia
|
||||||
|
root --- Background --- Rich
|
||||||
|
Background --- Poor
|
||||||
|
subgraph apa
|
||||||
|
Background
|
||||||
|
Poor
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
flowchart LR
|
||||||
|
root{mindmap} --- Origins --- Europe
|
||||||
|
Origins --> Asia
|
||||||
|
root --- Background --- Rich
|
||||||
|
Background --- Poor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram4" class="mermaid2">
|
<pre id="diagram4" class="mermaid2">
|
||||||
flowchart
|
flowchart
|
||||||
@@ -258,6 +465,44 @@ config:
|
|||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram4" class="mermaid2">
|
<pre id="diagram4" class="mermaid2">
|
||||||
---
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
flowchart LR
|
||||||
|
a
|
||||||
|
subgraph s0["APA"]
|
||||||
|
subgraph s8["APA"]
|
||||||
|
subgraph s1["APA"]
|
||||||
|
D{"X"}
|
||||||
|
E[Q]
|
||||||
|
end
|
||||||
|
subgraph s3["BAPA"]
|
||||||
|
F[Q]
|
||||||
|
I
|
||||||
|
end
|
||||||
|
D --> I
|
||||||
|
D --> I
|
||||||
|
D --> I
|
||||||
|
|
||||||
|
I{"X"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
flowchart LR
|
||||||
|
a
|
||||||
|
D{"Use the editor"}
|
||||||
|
|
||||||
|
D -- Mermaid js --> I{"fa:fa-code Text"}
|
||||||
|
D-->I
|
||||||
|
D-->I
|
||||||
|
</pre>
|
||||||
|
<pre id="diagram4" class="mermaid2">
|
||||||
|
---
|
||||||
config:
|
config:
|
||||||
layout: elk
|
layout: elk
|
||||||
---
|
---
|
||||||
|
379
cypress/platform/mindmap-layouts.html
Normal file
379
cypress/platform/mindmap-layouts.html
Normal file
@@ -0,0 +1,379 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<title>Mermaid Quick Test Page</title>
|
||||||
|
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
|
||||||
|
<style>
|
||||||
|
div.mermaid {
|
||||||
|
font-family: 'Courier New', Courier, monospace !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
id)I am a cloud(
|
||||||
|
id))I am a bang((
|
||||||
|
Tools
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
id)I am a cloud(
|
||||||
|
id))I am a bang((
|
||||||
|
Tools
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
id)I am a cloud(
|
||||||
|
id))I am a bang((
|
||||||
|
Tools
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
Origins
|
||||||
|
Long history
|
||||||
|
::icon(fa fa-book)
|
||||||
|
Popularisation
|
||||||
|
British popular psychology author Tony Buzan
|
||||||
|
Research
|
||||||
|
On effectiveness<br/>and features
|
||||||
|
On Automatic creation
|
||||||
|
Uses
|
||||||
|
Creative techniques
|
||||||
|
Strategic planning
|
||||||
|
Argument mapping
|
||||||
|
Tools
|
||||||
|
id)I am a cloud(
|
||||||
|
id))I am a bang((
|
||||||
|
Tools
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
B
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
D
|
||||||
|
apa5[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
B
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
D
|
||||||
|
apa5[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
B
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
D
|
||||||
|
apa5[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
a
|
||||||
|
apa[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa2[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
B
|
||||||
|
apa3[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
D
|
||||||
|
apa5[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
apa4[I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on. I am a long long multline string passing several levels of text. Lorum ipsum and so on]
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
((This is a mindmap))
|
||||||
|
child1
|
||||||
|
grandchild 1
|
||||||
|
grandchild 2
|
||||||
|
child2
|
||||||
|
grandchild 3
|
||||||
|
grandchild 4
|
||||||
|
child3
|
||||||
|
grandchild 5
|
||||||
|
grandchild 6
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: dagre
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
((This is a mindmap))
|
||||||
|
child1
|
||||||
|
grandchild 1
|
||||||
|
grandchild 2
|
||||||
|
child2
|
||||||
|
grandchild 3
|
||||||
|
grandchild 4
|
||||||
|
child3
|
||||||
|
grandchild 5
|
||||||
|
grandchild 6
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: elk
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
((This is a mindmap))
|
||||||
|
child1
|
||||||
|
grandchild 1
|
||||||
|
grandchild 2
|
||||||
|
child2
|
||||||
|
grandchild 3
|
||||||
|
grandchild 4
|
||||||
|
child3
|
||||||
|
grandchild 5
|
||||||
|
grandchild 6
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: cose-bilkent
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
((This is a mindmap))
|
||||||
|
child1
|
||||||
|
grandchild 1
|
||||||
|
grandchild 2
|
||||||
|
child2
|
||||||
|
grandchild 3
|
||||||
|
grandchild 4
|
||||||
|
child3
|
||||||
|
grandchild 5
|
||||||
|
grandchild 6
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from '/mermaid.esm.mjs';
|
||||||
|
mermaid.initialize({
|
||||||
|
theme: 'default',
|
||||||
|
logLevel: 3,
|
||||||
|
securityLevel: 'loose',
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -10,7 +10,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Block diagram demos</h1>
|
<h1>Block diagram demos</h1>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 1
|
columns 1
|
||||||
db(("DB"))
|
db(("DB"))
|
||||||
blockArrowId6<[" "]>(down)
|
blockArrowId6<[" "]>(down)
|
||||||
@@ -26,7 +26,7 @@ columns 1
|
|||||||
style B fill:#f9F,stroke:#333,stroke-width:4px
|
style B fill:#f9F,stroke:#333,stroke-width:4px
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
A1["square"]
|
A1["square"]
|
||||||
B1("rounded")
|
B1("rounded")
|
||||||
C1(("circle"))
|
C1(("circle"))
|
||||||
@@ -36,7 +36,7 @@ block-beta
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
A1(["stadium"])
|
A1(["stadium"])
|
||||||
A2[["subroutine"]]
|
A2[["subroutine"]]
|
||||||
B1[("cylinder")]
|
B1[("cylinder")]
|
||||||
@@ -48,7 +48,7 @@ block-beta
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
block:e:4
|
block:e:4
|
||||||
columns 2
|
columns 2
|
||||||
f
|
f
|
||||||
@@ -57,7 +57,7 @@ block-beta
|
|||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
block:e:4
|
block:e:4
|
||||||
columns 2
|
columns 2
|
||||||
f
|
f
|
||||||
@@ -67,7 +67,7 @@ block-beta
|
|||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a:3
|
a:3
|
||||||
block:e:3
|
block:e:3
|
||||||
@@ -80,7 +80,7 @@ block-beta
|
|||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 4
|
columns 4
|
||||||
a b c d
|
a b c d
|
||||||
block:e:4
|
block:e:4
|
||||||
@@ -97,19 +97,19 @@ flowchart LR
|
|||||||
X-- "a label" -->z
|
X-- "a label" -->z
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 5
|
columns 5
|
||||||
A space B
|
A space B
|
||||||
A --x B
|
A --x B
|
||||||
</pre>
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a["A wide one"] b:2 c:2 d
|
a["A wide one"] b:2 c:2 d
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a b c
|
a b c
|
||||||
e:3
|
e:3
|
||||||
@@ -117,7 +117,7 @@ columns 3
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
block-beta
|
block
|
||||||
|
|
||||||
A1:3
|
A1:3
|
||||||
A2:1
|
A2:1
|
||||||
|
@@ -20,12 +20,14 @@
|
|||||||
width: 800
|
width: 800
|
||||||
nodeAlignment: left
|
nodeAlignment: left
|
||||||
---
|
---
|
||||||
sankey-beta
|
sankey
|
||||||
Revenue,Expenses,10
|
a,b,8
|
||||||
Revenue,Profit,10
|
b,c,8
|
||||||
Expenses,Manufacturing,5
|
c,d,8
|
||||||
Expenses,Tax,3
|
d,e,8
|
||||||
Expenses,Research,2
|
|
||||||
|
x,c,4
|
||||||
|
c,y,4
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h2>Energy flow</h2>
|
<h2>Energy flow</h2>
|
||||||
@@ -40,7 +42,7 @@
|
|||||||
linkColor: gradient
|
linkColor: gradient
|
||||||
nodeAlignment: justify
|
nodeAlignment: justify
|
||||||
---
|
---
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Agricultural 'waste',Bio-conversion,124.729
|
Agricultural 'waste',Bio-conversion,124.729
|
||||||
Bio-conversion,Liquid,0.597
|
Bio-conversion,Liquid,0.597
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>XY Charts demos</h1>
|
<h1>XY Charts demos</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue (in $)"
|
title "Sales Revenue (in $)"
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<h1>XY Charts horizontal</h1>
|
<h1>XY Charts horizontal</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta horizontal
|
xychart horizontal
|
||||||
title "Basic xychart"
|
title "Basic xychart"
|
||||||
x-axis "this is x axis" [category1, "category 2", category3, category4]
|
x-axis "this is x axis" [category1, "category 2", category3, category4]
|
||||||
y-axis yaxisText 10 --> 150
|
y-axis yaxisText 10 --> 150
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<h1>XY Charts only lines and bar</h1>
|
<h1>XY Charts only lines and bar</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
line [23, 46, 77, 34]
|
line [23, 46, 77, 34]
|
||||||
line [45, 32, 33, 12]
|
line [45, 32, 33, 12]
|
||||||
line [87, 54, 99, 85]
|
line [87, 54, 99, 85]
|
||||||
@@ -48,13 +48,13 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<h1>XY Charts with +ve and -ve numbers</h1>
|
<h1>XY Charts with +ve and -ve numbers</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
line [+1.3, .6, 2.4, -.34]
|
line [+1.3, .6, 2.4, -.34]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h1>XY Charts Bar with multiple category</h1>
|
<h1>XY Charts Bar with multiple category</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
title "Basic xychart with many categories"
|
title "Basic xychart with many categories"
|
||||||
x-axis "this is x axis" [category1, "category 2", category3, category4, category5, category6, category7]
|
x-axis "this is x axis" [category1, "category 2", category3, category4, category5, category6, category7]
|
||||||
y-axis yaxisText 10 --> 150
|
y-axis yaxisText 10 --> 150
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<h1>XY Charts line with multiple category</h1>
|
<h1>XY Charts line with multiple category</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
title "Line chart with many category"
|
title "Line chart with many category"
|
||||||
x-axis "this is x axis" [category1, "category 2", category3, category4, category5, category6, category7]
|
x-axis "this is x axis" [category1, "category 2", category3, category4, category5, category6, category7]
|
||||||
y-axis yaxisText 10 --> 150
|
y-axis yaxisText 10 --> 150
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<h1>XY Charts category with large text</h1>
|
<h1>XY Charts category with large text</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
xychart-beta
|
xychart
|
||||||
title "Basic xychart with many categories with category overlap"
|
title "Basic xychart with many categories with category overlap"
|
||||||
x-axis "this is x axis" [category1, "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.", category3, category4, category5, category6, category7]
|
x-axis "this is x axis" [category1, "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.", category3, category4, category5, category6, category7]
|
||||||
y-axis yaxisText 10 --> 150
|
y-axis yaxisText 10 --> 150
|
||||||
@@ -89,7 +89,7 @@ config:
|
|||||||
height: 20
|
height: 20
|
||||||
plotReservedSpacePercent: 100
|
plotReservedSpacePercent: 100
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
line [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
line [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ config:
|
|||||||
height: 20
|
height: 20
|
||||||
plotReservedSpacePercent: 100
|
plotReservedSpacePercent: 100
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
bar [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
bar [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ config:
|
|||||||
chartOrientation: horizontal
|
chartOrientation: horizontal
|
||||||
plotReservedSpacePercent: 60
|
plotReservedSpacePercent: 60
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -162,7 +162,7 @@ config:
|
|||||||
xAxisLineColor: "#87ceeb"
|
xAxisLineColor: "#87ceeb"
|
||||||
plotColorPalette: "#008000, #faba63"
|
plotColorPalette: "#008000, #faba63"
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
|
@@ -29,7 +29,8 @@ In GitHub, you first [**fork a mermaid repository**](https://github.com/mermaid-
|
|||||||
|
|
||||||
Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
|
Then you **clone** a copy to your local development machine (e.g. where you code) to make a copy with all the files to work with.
|
||||||
|
|
||||||
> **💡 Tip** > [Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
> **💡 Tip**
|
||||||
|
> [Here is a GitHub document that gives an overview of the process](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone git@github.com/your-fork/mermaid
|
git clone git@github.com/your-fork/mermaid
|
||||||
|
@@ -33,7 +33,8 @@ mindmap
|
|||||||
|
|
||||||
## Join the Development
|
## Join the Development
|
||||||
|
|
||||||
> **💡 Tip** > **Check out our** [**detailed contribution guide**](./contributing.md).
|
> **💡 Tip**
|
||||||
|
> **Check out our** [**detailed contribution guide**](./contributing.md).
|
||||||
|
|
||||||
Where to start:
|
Where to start:
|
||||||
|
|
||||||
@@ -47,7 +48,8 @@ Where to start:
|
|||||||
|
|
||||||
## A Question Or a Suggestion?
|
## A Question Or a Suggestion?
|
||||||
|
|
||||||
> **💡 Tip** > **Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
|
> **💡 Tip**
|
||||||
|
> **Have a look at** [**how to open an issue**](./questions-and-suggestions.md).
|
||||||
|
|
||||||
If you have faced a vulnerability [report it to us](./security.md).
|
If you have faced a vulnerability [report it to us](./security.md).
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ While directives allow you to change most of the default configuration settings,
|
|||||||
Mermaid basically supports two types of configuration options to be overridden by directives.
|
Mermaid basically supports two types of configuration options to be overridden by directives.
|
||||||
|
|
||||||
1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are:
|
1. _General/Top Level configurations_ : These are the configurations that are available and applied to all the diagram. **Some of the most important top-level** configurations are:
|
||||||
|
|
||||||
- theme
|
- theme
|
||||||
- fontFamily
|
- fontFamily
|
||||||
- logLevel
|
- logLevel
|
||||||
|
@@ -10,10 +10,6 @@
|
|||||||
|
|
||||||
# mermaid
|
# mermaid
|
||||||
|
|
||||||
## Classes
|
|
||||||
|
|
||||||
- [UnknownDiagramError](classes/UnknownDiagramError.md)
|
|
||||||
|
|
||||||
## Interfaces
|
## Interfaces
|
||||||
|
|
||||||
- [DetailedError](interfaces/DetailedError.md)
|
- [DetailedError](interfaces/DetailedError.md)
|
||||||
@@ -27,6 +23,7 @@
|
|||||||
- [RenderOptions](interfaces/RenderOptions.md)
|
- [RenderOptions](interfaces/RenderOptions.md)
|
||||||
- [RenderResult](interfaces/RenderResult.md)
|
- [RenderResult](interfaces/RenderResult.md)
|
||||||
- [RunOptions](interfaces/RunOptions.md)
|
- [RunOptions](interfaces/RunOptions.md)
|
||||||
|
- [UnknownDiagramError](interfaces/UnknownDiagramError.md)
|
||||||
|
|
||||||
## Type Aliases
|
## Type Aliases
|
||||||
|
|
||||||
|
@@ -1,159 +0,0 @@
|
|||||||
> **Warning**
|
|
||||||
>
|
|
||||||
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
|
||||||
>
|
|
||||||
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/mermaid/classes/UnknownDiagramError.md](../../../../../packages/mermaid/src/docs/config/setup/mermaid/classes/UnknownDiagramError.md).
|
|
||||||
|
|
||||||
[**mermaid**](../../README.md)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Class: UnknownDiagramError
|
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/errors.ts:1](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/errors.ts#L1)
|
|
||||||
|
|
||||||
## Extends
|
|
||||||
|
|
||||||
- `Error`
|
|
||||||
|
|
||||||
## Constructors
|
|
||||||
|
|
||||||
### new UnknownDiagramError()
|
|
||||||
|
|
||||||
> **new UnknownDiagramError**(`message`): [`UnknownDiagramError`](UnknownDiagramError.md)
|
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/errors.ts:2](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/errors.ts#L2)
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
##### message
|
|
||||||
|
|
||||||
`string`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
[`UnknownDiagramError`](UnknownDiagramError.md)
|
|
||||||
|
|
||||||
#### Overrides
|
|
||||||
|
|
||||||
`Error.constructor`
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### cause?
|
|
||||||
|
|
||||||
> `optional` **cause**: `unknown`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.cause`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### message
|
|
||||||
|
|
||||||
> **message**: `string`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1077
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.message`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### name
|
|
||||||
|
|
||||||
> **name**: `string`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1076
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.name`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### stack?
|
|
||||||
|
|
||||||
> `optional` **stack**: `string`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1078
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.stack`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### prepareStackTrace()?
|
|
||||||
|
|
||||||
> `static` `optional` **prepareStackTrace**: (`err`, `stackTraces`) => `any`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/@types+node\@22.13.5/node_modules/@types/node/globals.d.ts:143
|
|
||||||
|
|
||||||
Optional override for formatting stack traces
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
##### err
|
|
||||||
|
|
||||||
`Error`
|
|
||||||
|
|
||||||
##### stackTraces
|
|
||||||
|
|
||||||
`CallSite`\[]
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`any`
|
|
||||||
|
|
||||||
#### See
|
|
||||||
|
|
||||||
<https://v8.dev/docs/stack-trace-api#customizing-stack-traces>
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.prepareStackTrace`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### stackTraceLimit
|
|
||||||
|
|
||||||
> `static` **stackTraceLimit**: `number`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/@types+node\@22.13.5/node_modules/@types/node/globals.d.ts:145
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.stackTraceLimit`
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### captureStackTrace()
|
|
||||||
|
|
||||||
> `static` **captureStackTrace**(`targetObject`, `constructorOpt`?): `void`
|
|
||||||
|
|
||||||
Defined in: node_modules/.pnpm/@types+node\@22.13.5/node_modules/@types/node/globals.d.ts:136
|
|
||||||
|
|
||||||
Create .stack property on a target object
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
##### targetObject
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
##### constructorOpt?
|
|
||||||
|
|
||||||
`Function`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`void`
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`Error.captureStackTrace`
|
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: LayoutData
|
# Interface: LayoutData
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:145](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L145)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:170](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L170)
|
||||||
|
|
||||||
## Indexable
|
## Indexable
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:145](https://github.co
|
|||||||
|
|
||||||
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:148](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L148)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:173](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L173)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:148](https://github.co
|
|||||||
|
|
||||||
> **edges**: `Edge`\[]
|
> **edges**: `Edge`\[]
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:147](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L147)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:172](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L172)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -38,4 +38,4 @@ Defined in: [packages/mermaid/src/rendering-util/types.ts:147](https://github.co
|
|||||||
|
|
||||||
> **nodes**: `Node`\[]
|
> **nodes**: `Node`\[]
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/rendering-util/types.ts:146](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L146)
|
Defined in: [packages/mermaid/src/rendering-util/types.ts:171](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L171)
|
||||||
|
@@ -32,7 +32,7 @@ page.
|
|||||||
|
|
||||||
### detectType()
|
### detectType()
|
||||||
|
|
||||||
> **detectType**: (`text`, `config`?) => `string`
|
> **detectType**: (`text`, `config?`) => `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/mermaid.ts:449](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L449)
|
Defined in: [packages/mermaid/src/mermaid.ts:449](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L449)
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ An array of objects with the id of the diagram.
|
|||||||
|
|
||||||
### ~~init()~~
|
### ~~init()~~
|
||||||
|
|
||||||
> **init**: (`config`?, `nodes`?, `callback`?) => `Promise`<`void`>
|
> **init**: (`config?`, `nodes?`, `callback?`) => `Promise`<`void`>
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/mermaid.ts:442](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L442)
|
Defined in: [packages/mermaid/src/mermaid.ts:442](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L442)
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ Defined in: [packages/mermaid/src/mermaid.ts:442](https://github.com/mermaid-js/
|
|||||||
|
|
||||||
[`MermaidConfig`](MermaidConfig.md)
|
[`MermaidConfig`](MermaidConfig.md)
|
||||||
|
|
||||||
**Deprecated**, please set configuration in [initialize](Mermaid.md#initialize).
|
**Deprecated**, please set configuration in [initialize](#initialize).
|
||||||
|
|
||||||
##### nodes?
|
##### nodes?
|
||||||
|
|
||||||
@@ -141,13 +141,13 @@ Called once for each rendered diagram's id.
|
|||||||
|
|
||||||
#### Deprecated
|
#### Deprecated
|
||||||
|
|
||||||
Use [initialize](Mermaid.md#initialize) and [run](Mermaid.md#run) instead.
|
Use [initialize](#initialize) and [run](#run) instead.
|
||||||
|
|
||||||
Renders the mermaid diagrams
|
Renders the mermaid diagrams
|
||||||
|
|
||||||
#### Deprecated
|
#### Deprecated
|
||||||
|
|
||||||
Use [initialize](Mermaid.md#initialize) and [run](Mermaid.md#run) instead.
|
Use [initialize](#initialize) and [run](#run) instead.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ Configuration object for mermaid.
|
|||||||
|
|
||||||
### ~~mermaidAPI~~
|
### ~~mermaidAPI~~
|
||||||
|
|
||||||
> **mermaidAPI**: `Readonly`<{ `defaultConfig`: [`MermaidConfig`](MermaidConfig.md); `getConfig`: () => [`MermaidConfig`](MermaidConfig.md); `getDiagramFromText`: (`text`, `metadata`) => `Promise`<`Diagram`>; `getSiteConfig`: () => [`MermaidConfig`](MermaidConfig.md); `globalReset`: () => `void`; `initialize`: (`userOptions`) => `void`; `parse`: (`text`, `parseOptions`) => `Promise`<`false` | [`ParseResult`](ParseResult.md)>(`text`, `parseOptions`?) => `Promise`<[`ParseResult`](ParseResult.md)>; `render`: (`id`, `text`, `svgContainingElement`?) => `Promise`<[`RenderResult`](RenderResult.md)>; `reset`: () => `void`; `setConfig`: (`conf`) => [`MermaidConfig`](MermaidConfig.md); `updateSiteConfig`: (`conf`) => [`MermaidConfig`](MermaidConfig.md); }>
|
> **mermaidAPI**: `Readonly`<{ `defaultConfig`: [`MermaidConfig`](MermaidConfig.md); `getConfig`: () => [`MermaidConfig`](MermaidConfig.md); `getDiagramFromText`: (`text`, `metadata`) => `Promise`<`Diagram`>; `getSiteConfig`: () => [`MermaidConfig`](MermaidConfig.md); `globalReset`: () => `void`; `initialize`: (`userOptions`) => `void`; `parse`: {(`text`, `parseOptions`): `Promise`<`false` | [`ParseResult`](ParseResult.md)>; (`text`, `parseOptions?`): `Promise`<[`ParseResult`](ParseResult.md)>; }; `render`: (`id`, `text`, `svgContainingElement?`) => `Promise`<[`RenderResult`](RenderResult.md)>; `reset`: () => `void`; `setConfig`: (`conf`) => [`MermaidConfig`](MermaidConfig.md); `updateSiteConfig`: (`conf`) => [`MermaidConfig`](MermaidConfig.md); }>
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/mermaid.ts:436](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L436)
|
Defined in: [packages/mermaid/src/mermaid.ts:436](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L436)
|
||||||
|
|
||||||
@@ -184,73 +184,81 @@ Defined in: [packages/mermaid/src/mermaid.ts:436](https://github.com/mermaid-js/
|
|||||||
|
|
||||||
#### Deprecated
|
#### Deprecated
|
||||||
|
|
||||||
Use [parse](Mermaid.md#parse) and [render](Mermaid.md#render) instead. Please [open a discussion](https://github.com/mermaid-js/mermaid/discussions) if your use case does not fit the new API.
|
Use [parse](#parse) and [render](#render) instead. Please [open a discussion](https://github.com/mermaid-js/mermaid/discussions) if your use case does not fit the new API.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### parse()
|
### parse()
|
||||||
|
|
||||||
> **parse**: (`text`, `parseOptions`) => `Promise`<`false` | [`ParseResult`](ParseResult.md)>(`text`, `parseOptions`?) => `Promise`<[`ParseResult`](ParseResult.md)>
|
> **parse**: {(`text`, `parseOptions`): `Promise`<`false` | [`ParseResult`](ParseResult.md)>; (`text`, `parseOptions?`): `Promise`<[`ParseResult`](ParseResult.md)>; }
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/mermaid.ts:437](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L437)
|
Defined in: [packages/mermaid/src/mermaid.ts:437](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L437)
|
||||||
|
|
||||||
|
#### Call Signature
|
||||||
|
|
||||||
|
> (`text`, `parseOptions`): `Promise`<`false` | [`ParseResult`](ParseResult.md)>
|
||||||
|
|
||||||
Parse the text and validate the syntax.
|
Parse the text and validate the syntax.
|
||||||
|
|
||||||
#### Parameters
|
##### Parameters
|
||||||
|
|
||||||
##### text
|
###### text
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
The mermaid diagram definition.
|
The mermaid diagram definition.
|
||||||
|
|
||||||
##### parseOptions
|
###### parseOptions
|
||||||
|
|
||||||
[`ParseOptions`](ParseOptions.md) & `object`
|
[`ParseOptions`](ParseOptions.md) & `object`
|
||||||
|
|
||||||
Options for parsing.
|
Options for parsing.
|
||||||
|
|
||||||
#### Returns
|
##### Returns
|
||||||
|
|
||||||
`Promise`<`false` | [`ParseResult`](ParseResult.md)>
|
`Promise`<`false` | [`ParseResult`](ParseResult.md)>
|
||||||
|
|
||||||
An object with the `diagramType` set to type of the diagram if valid. Otherwise `false` if parseOptions.suppressErrors is `true`.
|
An object with the `diagramType` set to type of the diagram if valid. Otherwise `false` if parseOptions.suppressErrors is `true`.
|
||||||
|
|
||||||
#### See
|
##### See
|
||||||
|
|
||||||
[ParseOptions](ParseOptions.md)
|
[ParseOptions](ParseOptions.md)
|
||||||
|
|
||||||
#### Throws
|
##### Throws
|
||||||
|
|
||||||
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
|
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
|
||||||
|
|
||||||
|
#### Call Signature
|
||||||
|
|
||||||
|
> (`text`, `parseOptions?`): `Promise`<[`ParseResult`](ParseResult.md)>
|
||||||
|
|
||||||
Parse the text and validate the syntax.
|
Parse the text and validate the syntax.
|
||||||
|
|
||||||
#### Parameters
|
##### Parameters
|
||||||
|
|
||||||
##### text
|
###### text
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
The mermaid diagram definition.
|
The mermaid diagram definition.
|
||||||
|
|
||||||
##### parseOptions?
|
###### parseOptions?
|
||||||
|
|
||||||
[`ParseOptions`](ParseOptions.md)
|
[`ParseOptions`](ParseOptions.md)
|
||||||
|
|
||||||
Options for parsing.
|
Options for parsing.
|
||||||
|
|
||||||
#### Returns
|
##### Returns
|
||||||
|
|
||||||
`Promise`<[`ParseResult`](ParseResult.md)>
|
`Promise`<[`ParseResult`](ParseResult.md)>
|
||||||
|
|
||||||
An object with the `diagramType` set to type of the diagram if valid. Otherwise `false` if parseOptions.suppressErrors is `true`.
|
An object with the `diagramType` set to type of the diagram if valid. Otherwise `false` if parseOptions.suppressErrors is `true`.
|
||||||
|
|
||||||
#### See
|
##### See
|
||||||
|
|
||||||
[ParseOptions](ParseOptions.md)
|
[ParseOptions](ParseOptions.md)
|
||||||
|
|
||||||
#### Throws
|
##### Throws
|
||||||
|
|
||||||
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
|
Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
|
||||||
|
|
||||||
@@ -332,7 +340,7 @@ Defined in: [packages/mermaid/src/mermaid.ts:444](https://github.com/mermaid-js/
|
|||||||
|
|
||||||
### render()
|
### render()
|
||||||
|
|
||||||
> **render**: (`id`, `text`, `svgContainingElement`?) => `Promise`<[`RenderResult`](RenderResult.md)>
|
> **render**: (`id`, `text`, `svgContainingElement?`) => `Promise`<[`RenderResult`](RenderResult.md)>
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/mermaid.ts:438](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L438)
|
Defined in: [packages/mermaid/src/mermaid.ts:438](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaid.ts#L438)
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: ParseOptions
|
# Interface: ParseOptions
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:72](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L72)
|
Defined in: [packages/mermaid/src/types.ts:76](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L76)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:72](https://github.com/mermaid-js/mer
|
|||||||
|
|
||||||
> `optional` **suppressErrors**: `boolean`
|
> `optional` **suppressErrors**: `boolean`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:77](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L77)
|
Defined in: [packages/mermaid/src/types.ts:81](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L81)
|
||||||
|
|
||||||
If `true`, parse will return `false` instead of throwing error when the diagram is invalid.
|
If `true`, parse will return `false` instead of throwing error when the diagram is invalid.
|
||||||
The `parseError` function will not be called.
|
The `parseError` function will not be called.
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: ParseResult
|
# Interface: ParseResult
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:80](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L80)
|
Defined in: [packages/mermaid/src/types.ts:84](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L84)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:80](https://github.com/mermaid-js/mer
|
|||||||
|
|
||||||
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
> **config**: [`MermaidConfig`](MermaidConfig.md)
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:88](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L88)
|
Defined in: [packages/mermaid/src/types.ts:92](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L92)
|
||||||
|
|
||||||
The config passed as YAML frontmatter or directives
|
The config passed as YAML frontmatter or directives
|
||||||
|
|
||||||
@@ -28,6 +28,6 @@ The config passed as YAML frontmatter or directives
|
|||||||
|
|
||||||
> **diagramType**: `string`
|
> **diagramType**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:84](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L84)
|
Defined in: [packages/mermaid/src/types.ts:88](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L88)
|
||||||
|
|
||||||
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Interface: RenderResult
|
# Interface: RenderResult
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:98](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L98)
|
Defined in: [packages/mermaid/src/types.ts:102](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L102)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Defined in: [packages/mermaid/src/types.ts:98](https://github.com/mermaid-js/mer
|
|||||||
|
|
||||||
> `optional` **bindFunctions**: (`element`) => `void`
|
> `optional` **bindFunctions**: (`element`) => `void`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:116](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L116)
|
Defined in: [packages/mermaid/src/types.ts:120](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L120)
|
||||||
|
|
||||||
Bind function to be called after the svg has been inserted into the DOM.
|
Bind function to be called after the svg has been inserted into the DOM.
|
||||||
This is necessary for adding event listeners to the elements in the svg.
|
This is necessary for adding event listeners to the elements in the svg.
|
||||||
@@ -45,7 +45,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
|
|||||||
|
|
||||||
> **diagramType**: `string`
|
> **diagramType**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:106](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L106)
|
Defined in: [packages/mermaid/src/types.ts:110](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L110)
|
||||||
|
|
||||||
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||||
|
|
||||||
@@ -55,6 +55,6 @@ The diagram type, e.g. 'flowchart', 'sequence', etc.
|
|||||||
|
|
||||||
> **svg**: `string`
|
> **svg**: `string`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/types.ts:102](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L102)
|
Defined in: [packages/mermaid/src/types.ts:106](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L106)
|
||||||
|
|
||||||
The svg code for the rendered graph.
|
The svg code for the rendered graph.
|
||||||
|
65
docs/config/setup/mermaid/interfaces/UnknownDiagramError.md
Normal file
65
docs/config/setup/mermaid/interfaces/UnknownDiagramError.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||||
|
>
|
||||||
|
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/mermaid/interfaces/UnknownDiagramError.md](../../../../../packages/mermaid/src/docs/config/setup/mermaid/interfaces/UnknownDiagramError.md).
|
||||||
|
|
||||||
|
[**mermaid**](../../README.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Interface: UnknownDiagramError
|
||||||
|
|
||||||
|
Defined in: [packages/mermaid/src/errors.ts:1](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/errors.ts#L1)
|
||||||
|
|
||||||
|
## Extends
|
||||||
|
|
||||||
|
- `Error`
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### cause?
|
||||||
|
|
||||||
|
> `optional` **cause**: `unknown`
|
||||||
|
|
||||||
|
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
`Error.cause`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### message
|
||||||
|
|
||||||
|
> **message**: `string`
|
||||||
|
|
||||||
|
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1077
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
`Error.message`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### name
|
||||||
|
|
||||||
|
> **name**: `string`
|
||||||
|
|
||||||
|
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1076
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
`Error.name`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### stack?
|
||||||
|
|
||||||
|
> `optional` **stack**: `string`
|
||||||
|
|
||||||
|
Defined in: node_modules/.pnpm/typescript\@5.7.3/node_modules/typescript/lib/lib.es5.d.ts:1078
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
`Error.stack`
|
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
# Type Alias: InternalHelpers
|
# Type Alias: InternalHelpers
|
||||||
|
|
||||||
> **InternalHelpers**: _typeof_ `internalHelpers`
|
> **InternalHelpers** = _typeof_ `internalHelpers`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/internals.ts:33](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/internals.ts#L33)
|
Defined in: [packages/mermaid/src/internals.ts:33](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/internals.ts#L33)
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Type Alias: ParseErrorFunction()
|
# Type Alias: ParseErrorFunction()
|
||||||
|
|
||||||
> **ParseErrorFunction**: (`err`, `hash`?) => `void`
|
> **ParseErrorFunction** = (`err`, `hash?`) => `void`
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/Diagram.ts:10](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/Diagram.ts#L10)
|
Defined in: [packages/mermaid/src/Diagram.ts:10](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/Diagram.ts#L10)
|
||||||
|
|
||||||
|
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
# Type Alias: SVG
|
# Type Alias: SVG
|
||||||
|
|
||||||
> **SVG**: `d3.Selection`<`SVGSVGElement`, `unknown`, `Element` | `null`, `unknown`>
|
> **SVG** = `d3.Selection`<`SVGSVGElement`, `unknown`, `Element` | `null`, `unknown`>
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/diagram-api/types.ts:126](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagram-api/types.ts#L126)
|
Defined in: [packages/mermaid/src/diagram-api/types.ts:126](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagram-api/types.ts#L126)
|
||||||
|
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
# Type Alias: SVGGroup
|
# Type Alias: SVGGroup
|
||||||
|
|
||||||
> **SVGGroup**: `d3.Selection`<`SVGGElement`, `unknown`, `Element` | `null`, `unknown`>
|
> **SVGGroup** = `d3.Selection`<`SVGGElement`, `unknown`, `Element` | `null`, `unknown`>
|
||||||
|
|
||||||
Defined in: [packages/mermaid/src/diagram-api/types.ts:128](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagram-api/types.ts#L128)
|
Defined in: [packages/mermaid/src/diagram-api/types.ts:128](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagram-api/types.ts#L128)
|
||||||
|
63
docs/config/tidy-tree.md
Normal file
63
docs/config/tidy-tree.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
||||||
|
>
|
||||||
|
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/tidy-tree.md](../../packages/mermaid/src/docs/config/tidy-tree.md).
|
||||||
|
|
||||||
|
# Tidy-tree Layout Instructions
|
||||||
|
|
||||||
|
Instructions to use the Tidy-tree layout algorithm.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install non-layered-tidy-tree-layout
|
||||||
|
# or
|
||||||
|
yarn add non-layered-tidy-tree-layout
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
There's also a built version: `dist/non-layered-tidy-tree-layout.js` for use with browser `<script>` tag, or as a Javascript module.
|
||||||
|
|
||||||
|
## Tidy tree Layouts
|
||||||
|
|
||||||
|
Mermaid also supports a Tidy Tree layout for mindmaps.
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
```
|
||||||
|
|
||||||
|
### With bundlers
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @mermaid-js/layout-tidy-tree
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import mermaid from 'mermaid';
|
||||||
|
import tidyTreeLayouts from '@mermaid-js/layout-tidy-tree';
|
||||||
|
|
||||||
|
mermaid.registerLayoutLoaders(tidyTreeLayouts);
|
||||||
|
```
|
||||||
|
|
||||||
|
### With CDN
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
||||||
|
import tidyTreeLayouts from 'https://cdn.jsdelivr.net/npm/@mermaid-js/layout-tidy-tree@0/dist/mermaid-layout-tidy-tree.esm.min.mjs';
|
||||||
|
|
||||||
|
mermaid.registerLayoutLoaders(tidyTreeLayouts);
|
||||||
|
</script>
|
||||||
|
```
|
@@ -29,7 +29,6 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
|
|||||||
- **Plugins** - A plugin system for extending the functionality of Mermaid.
|
- **Plugins** - A plugin system for extending the functionality of Mermaid.
|
||||||
|
|
||||||
Official Mermaid Chart plugins:
|
Official Mermaid Chart plugins:
|
||||||
|
|
||||||
- [Mermaid Chart GPT](https://chatgpt.com/g/g-684cc36f30208191b21383b88650a45d-mermaid-chart-diagrams-and-charts)
|
- [Mermaid Chart GPT](https://chatgpt.com/g/g-684cc36f30208191b21383b88650a45d-mermaid-chart-diagrams-and-charts)
|
||||||
- [Confluence](https://marketplace.atlassian.com/apps/1234056/mermaid-chart-for-confluence?hosting=cloud&tab=overview)
|
- [Confluence](https://marketplace.atlassian.com/apps/1234056/mermaid-chart-for-confluence?hosting=cloud&tab=overview)
|
||||||
- [Jira](https://marketplace.atlassian.com/apps/1234810/mermaid-chart-for-jira?tab=overview&hosting=cloud)
|
- [Jira](https://marketplace.atlassian.com/apps/1234810/mermaid-chart-for-jira?tab=overview&hosting=cloud)
|
||||||
|
@@ -35,13 +35,11 @@ The Mermaid Chart team is excited to introduce a new Visual Editor for Flowchart
|
|||||||
Learn more:
|
Learn more:
|
||||||
|
|
||||||
- Visual Editor For Flowcharts
|
- Visual Editor For Flowcharts
|
||||||
|
|
||||||
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-releases-new-visual-editor-for-flowcharts)
|
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-releases-new-visual-editor-for-flowcharts)
|
||||||
|
|
||||||
- [Demo video](https://www.youtube.com/watch?v=5aja0gijoO0)
|
- [Demo video](https://www.youtube.com/watch?v=5aja0gijoO0)
|
||||||
|
|
||||||
- Visual Editor For Sequence diagrams
|
- Visual Editor For Sequence diagrams
|
||||||
|
|
||||||
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams)
|
- [Blog post](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams)
|
||||||
|
|
||||||
- [Demo video](https://youtu.be/imc2u5_N6Dc)
|
- [Demo video](https://youtu.be/imc2u5_N6Dc)
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
## Introduction to Block Diagrams
|
## Introduction to Block Diagrams
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 1
|
columns 1
|
||||||
db(("DB"))
|
db(("DB"))
|
||||||
blockArrowId6<[" "]>(down)
|
blockArrowId6<[" "]>(down)
|
||||||
@@ -26,7 +26,7 @@ columns 1
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 1
|
columns 1
|
||||||
db(("DB"))
|
db(("DB"))
|
||||||
blockArrowId6<[" "]>(down)
|
blockArrowId6<[" "]>(down)
|
||||||
@@ -80,12 +80,12 @@ At its core, a block diagram consists of blocks representing different entities
|
|||||||
To create a simple block diagram with three blocks labeled 'a', 'b', and 'c', the syntax is as follows:
|
To create a simple block diagram with three blocks labeled 'a', 'b', and 'c', the syntax is as follows:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
a b c
|
a b c
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
a b c
|
a b c
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -101,13 +101,13 @@ While simple block diagrams are linear and straightforward, more complex systems
|
|||||||
In scenarios where you need to distribute blocks across multiple columns, you can specify the number of columns and arrange the blocks accordingly. Here's how to create a block diagram with three columns and four blocks, where the fourth block appears in a second row:
|
In scenarios where you need to distribute blocks across multiple columns, you can specify the number of columns and arrange the blocks accordingly. Here's how to create a block diagram with three columns and four blocks, where the fourth block appears in a second row:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a b c d
|
a b c d
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a b c d
|
a b c d
|
||||||
```
|
```
|
||||||
@@ -130,13 +130,13 @@ In more complex diagrams, you may need blocks that span multiple columns to emph
|
|||||||
To create a block diagram where one block spans across two columns, you can specify the desired width for each block:
|
To create a block diagram where one block spans across two columns, you can specify the desired width for each block:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a["A label"] b:2 c:2 d
|
a["A label"] b:2 c:2 d
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a["A label"] b:2 c:2 d
|
a["A label"] b:2 c:2 d
|
||||||
```
|
```
|
||||||
@@ -153,7 +153,7 @@ Composite blocks, or blocks within blocks, are an advanced feature in Mermaid's
|
|||||||
Creating a composite block involves defining a parent block and then nesting other blocks within it. Here's how to define a composite block with nested elements:
|
Creating a composite block involves defining a parent block and then nesting other blocks within it. Here's how to define a composite block with nested elements:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
block
|
block
|
||||||
D
|
D
|
||||||
end
|
end
|
||||||
@@ -161,7 +161,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
block
|
block
|
||||||
D
|
D
|
||||||
end
|
end
|
||||||
@@ -180,7 +180,7 @@ Mermaid also allows for dynamic adjustment of column widths based on the content
|
|||||||
In diagrams with varying block sizes, Mermaid automatically adjusts the column widths to fit the largest block in each column. Here's an example:
|
In diagrams with varying block sizes, Mermaid automatically adjusts the column widths to fit the largest block in each column. Here's an example:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a:3
|
a:3
|
||||||
block:group1:2
|
block:group1:2
|
||||||
@@ -195,7 +195,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a:3
|
a:3
|
||||||
block:group1:2
|
block:group1:2
|
||||||
@@ -215,7 +215,7 @@ This example demonstrates how Mermaid dynamically adjusts the width of the colum
|
|||||||
In scenarios where you need to stack blocks horizontally, you can use column width to accomplish the task. Blocks can be arranged vertically by putting them in a single column. Here is how you can create a block diagram in which 4 blocks are stacked on top of each other:
|
In scenarios where you need to stack blocks horizontally, you can use column width to accomplish the task. Blocks can be arranged vertically by putting them in a single column. Here is how you can create a block diagram in which 4 blocks are stacked on top of each other:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
block
|
block
|
||||||
columns 1
|
columns 1
|
||||||
a["A label"] b c d
|
a["A label"] b c d
|
||||||
@@ -223,7 +223,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
block
|
block
|
||||||
columns 1
|
columns 1
|
||||||
a["A label"] b c d
|
a["A label"] b c d
|
||||||
@@ -247,12 +247,12 @@ Mermaid supports a range of block shapes to suit different diagramming needs, fr
|
|||||||
To create a block with round edges, which can be used to represent a softer or more flexible component:
|
To create a block with round edges, which can be used to represent a softer or more flexible component:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1("This is the text in the box")
|
id1("This is the text in the box")
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1("This is the text in the box")
|
id1("This is the text in the box")
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -261,12 +261,12 @@ block-beta
|
|||||||
A stadium-shaped block, resembling an elongated circle, can be used for components that are process-oriented:
|
A stadium-shaped block, resembling an elongated circle, can be used for components that are process-oriented:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1(["This is the text in the box"])
|
id1(["This is the text in the box"])
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1(["This is the text in the box"])
|
id1(["This is the text in the box"])
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -275,12 +275,12 @@ block-beta
|
|||||||
For representing subroutines or contained processes, a block with double vertical lines is useful:
|
For representing subroutines or contained processes, a block with double vertical lines is useful:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1[["This is the text in the box"]]
|
id1[["This is the text in the box"]]
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1[["This is the text in the box"]]
|
id1[["This is the text in the box"]]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -289,12 +289,12 @@ block-beta
|
|||||||
The cylindrical shape is ideal for representing databases or storage components:
|
The cylindrical shape is ideal for representing databases or storage components:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1[("Database")]
|
id1[("Database")]
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1[("Database")]
|
id1[("Database")]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -303,12 +303,12 @@ block-beta
|
|||||||
A circle can be used for centralized or pivotal components:
|
A circle can be used for centralized or pivotal components:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1(("This is the text in the circle"))
|
id1(("This is the text in the circle"))
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1(("This is the text in the circle"))
|
id1(("This is the text in the circle"))
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -319,36 +319,36 @@ For decision points, use a rhombus, and for unique or specialized processes, asy
|
|||||||
**Asymmetric**
|
**Asymmetric**
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1>"This is the text in the box"]
|
id1>"This is the text in the box"]
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1>"This is the text in the box"]
|
id1>"This is the text in the box"]
|
||||||
```
|
```
|
||||||
|
|
||||||
**Rhombus**
|
**Rhombus**
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1{"This is the text in the box"}
|
id1{"This is the text in the box"}
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1{"This is the text in the box"}
|
id1{"This is the text in the box"}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Hexagon**
|
**Hexagon**
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1{{"This is the text in the box"}}
|
id1{{"This is the text in the box"}}
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1{{"This is the text in the box"}}
|
id1{{"This is the text in the box"}}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ block-beta
|
|||||||
Parallelogram and trapezoid shapes are perfect for inputs/outputs and transitional processes:
|
Parallelogram and trapezoid shapes are perfect for inputs/outputs and transitional processes:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1[/"This is the text in the box"/]
|
id1[/"This is the text in the box"/]
|
||||||
id2[\"This is the text in the box"\]
|
id2[\"This is the text in the box"\]
|
||||||
A[/"Christmas"\]
|
A[/"Christmas"\]
|
||||||
@@ -365,7 +365,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1[/"This is the text in the box"/]
|
id1[/"This is the text in the box"/]
|
||||||
id2[\"This is the text in the box"\]
|
id2[\"This is the text in the box"\]
|
||||||
A[/"Christmas"\]
|
A[/"Christmas"\]
|
||||||
@@ -377,12 +377,12 @@ block-beta
|
|||||||
For highlighting critical or high-priority components, a double circle can be effective:
|
For highlighting critical or high-priority components, a double circle can be effective:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1((("This is the text in the circle")))
|
id1((("This is the text in the circle")))
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1((("This is the text in the circle")))
|
id1((("This is the text in the circle")))
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ Mermaid also offers unique shapes like block arrows and space blocks for directi
|
|||||||
Block arrows can visually indicate direction or flow within a process:
|
Block arrows can visually indicate direction or flow within a process:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
blockArrowId<["Label"]>(right)
|
blockArrowId<["Label"]>(right)
|
||||||
blockArrowId2<["Label"]>(left)
|
blockArrowId2<["Label"]>(left)
|
||||||
blockArrowId3<["Label"]>(up)
|
blockArrowId3<["Label"]>(up)
|
||||||
@@ -406,7 +406,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
blockArrowId<["Label"]>(right)
|
blockArrowId<["Label"]>(right)
|
||||||
blockArrowId2<["Label"]>(left)
|
blockArrowId2<["Label"]>(left)
|
||||||
blockArrowId3<["Label"]>(up)
|
blockArrowId3<["Label"]>(up)
|
||||||
@@ -421,14 +421,14 @@ block-beta
|
|||||||
Space blocks can be used to create intentional empty spaces in the diagram, which is useful for layout and readability:
|
Space blocks can be used to create intentional empty spaces in the diagram, which is useful for layout and readability:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a space b
|
a space b
|
||||||
c d e
|
c d e
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
a space b
|
a space b
|
||||||
c d e
|
c d e
|
||||||
@@ -437,12 +437,12 @@ block-beta
|
|||||||
or
|
or
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
ida space:3 idb idc
|
ida space:3 idb idc
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
ida space:3 idb idc
|
ida space:3 idb idc
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -467,13 +467,13 @@ The most fundamental aspect of connecting blocks is the use of arrows or links.
|
|||||||
A simple link with an arrow can be created to show direction or flow from one block to another:
|
A simple link with an arrow can be created to show direction or flow from one block to another:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A-->B
|
A-->B
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A-->B
|
A-->B
|
||||||
```
|
```
|
||||||
@@ -490,13 +490,13 @@ Example - Text with Links
|
|||||||
To add text to a link, the syntax includes the text within the link definition:
|
To add text to a link, the syntax includes the text within the link definition:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A space:2 B
|
A space:2 B
|
||||||
A-- "X" -->B
|
A-- "X" -->B
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A space:2 B
|
A space:2 B
|
||||||
A-- "X" -->B
|
A-- "X" -->B
|
||||||
```
|
```
|
||||||
@@ -506,7 +506,7 @@ This example show how to add descriptive text to the links, enhancing the inform
|
|||||||
Example - Edges and Styles:
|
Example - Edges and Styles:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 1
|
columns 1
|
||||||
db(("DB"))
|
db(("DB"))
|
||||||
blockArrowId6<[" "]>(down)
|
blockArrowId6<[" "]>(down)
|
||||||
@@ -523,7 +523,7 @@ columns 1
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 1
|
columns 1
|
||||||
db(("DB"))
|
db(("DB"))
|
||||||
blockArrowId6<[" "]>(down)
|
blockArrowId6<[" "]>(down)
|
||||||
@@ -552,7 +552,7 @@ Mermaid enables detailed styling of individual blocks, allowing you to apply var
|
|||||||
To apply custom styles to a block, you can use the `style` keyword followed by the block identifier and the desired CSS properties:
|
To apply custom styles to a block, you can use the `style` keyword followed by the block identifier and the desired CSS properties:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
id1 space id2
|
id1 space id2
|
||||||
id1("Start")-->id2("Stop")
|
id1("Start")-->id2("Stop")
|
||||||
style id1 fill:#636,stroke:#333,stroke-width:4px
|
style id1 fill:#636,stroke:#333,stroke-width:4px
|
||||||
@@ -560,7 +560,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
id1 space id2
|
id1 space id2
|
||||||
id1("Start")-->id2("Stop")
|
id1("Start")-->id2("Stop")
|
||||||
style id1 fill:#636,stroke:#333,stroke-width:4px
|
style id1 fill:#636,stroke:#333,stroke-width:4px
|
||||||
@@ -574,7 +574,7 @@ Mermaid enables applying styling to classes, which could make styling easier if
|
|||||||
#### Example - Styling a Single Class
|
#### Example - Styling a Single Class
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A-->B
|
A-->B
|
||||||
classDef blue fill:#6e6ce6,stroke:#333,stroke-width:4px;
|
classDef blue fill:#6e6ce6,stroke:#333,stroke-width:4px;
|
||||||
@@ -583,7 +583,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A-->B
|
A-->B
|
||||||
classDef blue fill:#6e6ce6,stroke:#333,stroke-width:4px;
|
classDef blue fill:#6e6ce6,stroke:#333,stroke-width:4px;
|
||||||
@@ -608,7 +608,7 @@ Combining the elements of structure, linking, and styling, we can create compreh
|
|||||||
Illustrating a simple software system architecture with interconnected components:
|
Illustrating a simple software system architecture with interconnected components:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
Frontend blockArrowId6<[" "]>(right) Backend
|
Frontend blockArrowId6<[" "]>(right) Backend
|
||||||
space:2 down<[" "]>(down)
|
space:2 down<[" "]>(down)
|
||||||
@@ -621,7 +621,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
Frontend blockArrowId6<[" "]>(right) Backend
|
Frontend blockArrowId6<[" "]>(right) Backend
|
||||||
space:2 down<[" "]>(down)
|
space:2 down<[" "]>(down)
|
||||||
@@ -640,7 +640,7 @@ This example shows a basic architecture with a frontend, backend, and database.
|
|||||||
Representing a business process flow with decision points and multiple stages:
|
Representing a business process flow with decision points and multiple stages:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
Start(("Start")) space:2
|
Start(("Start")) space:2
|
||||||
down<[" "]>(down) space:2
|
down<[" "]>(down) space:2
|
||||||
@@ -653,7 +653,7 @@ block-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
columns 3
|
columns 3
|
||||||
Start(("Start")) space:2
|
Start(("Start")) space:2
|
||||||
down<[" "]>(down) space:2
|
down<[" "]>(down) space:2
|
||||||
@@ -682,7 +682,7 @@ Understanding and avoiding common syntax errors is key to a smooth experience wi
|
|||||||
A common mistake is incorrect linking syntax, which can lead to unexpected results or broken diagrams:
|
A common mistake is incorrect linking syntax, which can lead to unexpected results or broken diagrams:
|
||||||
|
|
||||||
```
|
```
|
||||||
block-beta
|
block
|
||||||
A - B
|
A - B
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -690,13 +690,13 @@ block-beta
|
|||||||
Ensure that links between blocks are correctly specified with arrows (--> or ---) to define the direction and type of connection. Also remember that one of the fundamentals for block diagram is to give the author full control of where the boxes are positioned so in the example you need to add a space between the boxes:
|
Ensure that links between blocks are correctly specified with arrows (--> or ---) to define the direction and type of connection. Also remember that one of the fundamentals for block diagram is to give the author full control of where the boxes are positioned so in the example you need to add a space between the boxes:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A --> B
|
A --> B
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A space B
|
A space B
|
||||||
A --> B
|
A --> B
|
||||||
```
|
```
|
||||||
@@ -706,13 +706,13 @@ block-beta
|
|||||||
Applying styles in the wrong context or with incorrect syntax can lead to blocks not being styled as intended:
|
Applying styles in the wrong context or with incorrect syntax can lead to blocks not being styled as intended:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A
|
A
|
||||||
style A fill#969;
|
style A fill#969;
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A
|
A
|
||||||
style A fill#969;
|
style A fill#969;
|
||||||
```
|
```
|
||||||
@@ -721,14 +721,14 @@ Applying styles in the wrong context or with incorrect syntax can lead to blocks
|
|||||||
Correct the syntax by ensuring proper separation of style properties with commas and using the correct CSS property format:
|
Correct the syntax by ensuring proper separation of style properties with commas and using the correct CSS property format:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
block-beta
|
block
|
||||||
A
|
A
|
||||||
style A fill:#969,stroke:#333;
|
style A fill:#969,stroke:#333;
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
block-beta
|
block
|
||||||
A
|
A
|
||||||
style A fill:#969,stroke:#333;
|
style A fill:#969,stroke:#333;
|
||||||
|
|
||||||
|
@@ -139,7 +139,6 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [ ] Legend
|
- [ ] Legend
|
||||||
|
|
||||||
- [x] System Context
|
- [x] System Context
|
||||||
|
|
||||||
- [x] Person(alias, label, ?descr, ?sprite, ?tags, $link)
|
- [x] Person(alias, label, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] Person_Ext
|
- [x] Person_Ext
|
||||||
- [x] System(alias, label, ?descr, ?sprite, ?tags, $link)
|
- [x] System(alias, label, ?descr, ?sprite, ?tags, $link)
|
||||||
@@ -153,7 +152,6 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] System_Boundary
|
- [x] System_Boundary
|
||||||
|
|
||||||
- [x] Container diagram
|
- [x] Container diagram
|
||||||
|
|
||||||
- [x] Container(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Container(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] ContainerDb
|
- [x] ContainerDb
|
||||||
- [x] ContainerQueue
|
- [x] ContainerQueue
|
||||||
@@ -163,7 +161,6 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] Container_Boundary(alias, label, ?tags, $link)
|
- [x] Container_Boundary(alias, label, ?tags, $link)
|
||||||
|
|
||||||
- [x] Component diagram
|
- [x] Component diagram
|
||||||
|
|
||||||
- [x] Component(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Component(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] ComponentDb
|
- [x] ComponentDb
|
||||||
- [x] ComponentQueue
|
- [x] ComponentQueue
|
||||||
@@ -172,18 +169,15 @@ The following unfinished features are not supported in the short term.
|
|||||||
- [x] ComponentQueue_Ext
|
- [x] ComponentQueue_Ext
|
||||||
|
|
||||||
- [x] Dynamic diagram
|
- [x] Dynamic diagram
|
||||||
|
|
||||||
- [x] RelIndex(index, from, to, label, ?tags, $link)
|
- [x] RelIndex(index, from, to, label, ?tags, $link)
|
||||||
|
|
||||||
- [x] Deployment diagram
|
- [x] Deployment diagram
|
||||||
|
|
||||||
- [x] Deployment_Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link)
|
- [x] Deployment_Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link): short name of Deployment_Node()
|
- [x] Node(alias, label, ?type, ?descr, ?sprite, ?tags, $link): short name of Deployment_Node()
|
||||||
- [x] Node_L(alias, label, ?type, ?descr, ?sprite, ?tags, $link): left aligned Node()
|
- [x] Node_L(alias, label, ?type, ?descr, ?sprite, ?tags, $link): left aligned Node()
|
||||||
- [x] Node_R(alias, label, ?type, ?descr, ?sprite, ?tags, $link): right aligned Node()
|
- [x] Node_R(alias, label, ?type, ?descr, ?sprite, ?tags, $link): right aligned Node()
|
||||||
|
|
||||||
- [x] Relationship Types
|
- [x] Relationship Types
|
||||||
|
|
||||||
- [x] Rel(from, to, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
- [x] Rel(from, to, label, ?techn, ?descr, ?sprite, ?tags, $link)
|
||||||
- [x] BiRel (bidirectional relationship)
|
- [x] BiRel (bidirectional relationship)
|
||||||
- [x] Rel_U, Rel_Up
|
- [x] Rel_U, Rel_Up
|
||||||
|
@@ -325,8 +325,10 @@ This syntax creates a node A as a rectangle. It renders in the same way as `A["A
|
|||||||
Below is a comprehensive list of the newly introduced shapes and their corresponding semantic meanings, short names, and aliases:
|
Below is a comprehensive list of the newly introduced shapes and their corresponding semantic meanings, short names, and aliases:
|
||||||
|
|
||||||
| **Semantic Name** | **Shape Name** | **Short Name** | **Description** | **Alias Supported** |
|
| **Semantic Name** | **Shape Name** | **Short Name** | **Description** | **Alias Supported** |
|
||||||
| --------------------------------- | ---------------------- | -------------- | ------------------------------ | ---------------------------------------------------------------- |
|
| --------------------------------- | ---------------------- | ----------------- | ------------------------------ | ---------------------------------------------------------------- |
|
||||||
|
| Bang | Bang | `bang` | Bang | `bang` |
|
||||||
| Card | Notched Rectangle | `notch-rect` | Represents a card | `card`, `notched-rectangle` |
|
| Card | Notched Rectangle | `notch-rect` | Represents a card | `card`, `notched-rectangle` |
|
||||||
|
| Cloud | Cloud | `cloud` | cloud | `cloud` |
|
||||||
| Collate | Hourglass | `hourglass` | Represents a collate operation | `collate`, `hourglass` |
|
| Collate | Hourglass | `hourglass` | Represents a collate operation | `collate`, `hourglass` |
|
||||||
| Com Link | Lightning Bolt | `bolt` | Communication link | `com-link`, `lightning-bolt` |
|
| Com Link | Lightning Bolt | `bolt` | Communication link | `com-link`, `lightning-bolt` |
|
||||||
| Comment | Curly Brace | `brace` | Adds a comment | `brace-l`, `comment` |
|
| Comment | Curly Brace | `brace` | Adds a comment | `brace-l`, `comment` |
|
||||||
@@ -336,6 +338,7 @@ Below is a comprehensive list of the newly introduced shapes and their correspon
|
|||||||
| Data Input/Output | Lean Left | `lean-l` | Represents output or input | `lean-left`, `out-in` |
|
| Data Input/Output | Lean Left | `lean-l` | Represents output or input | `lean-left`, `out-in` |
|
||||||
| Database | Cylinder | `cyl` | Database storage | `cylinder`, `database`, `db` |
|
| Database | Cylinder | `cyl` | Database storage | `cylinder`, `database`, `db` |
|
||||||
| Decision | Diamond | `diam` | Decision-making step | `decision`, `diamond`, `question` |
|
| Decision | Diamond | `diam` | Decision-making step | `decision`, `diamond`, `question` |
|
||||||
|
| Default Mindmap Node | defaultMindmapNode | `default-mindmap` | defaultMindmapNode | `default-mindmap`, `defaultMindmapNode` |
|
||||||
| Delay | Half-Rounded Rectangle | `delay` | Represents a delay | `half-rounded-rectangle` |
|
| Delay | Half-Rounded Rectangle | `delay` | Represents a delay | `half-rounded-rectangle` |
|
||||||
| Direct Access Storage | Horizontal Cylinder | `h-cyl` | Direct access storage | `das`, `horizontal-cylinder` |
|
| Direct Access Storage | Horizontal Cylinder | `h-cyl` | Direct access storage | `das`, `horizontal-cylinder` |
|
||||||
| Disk Storage | Lined Cylinder | `lin-cyl` | Disk storage | `disk`, `lined-cylinder` |
|
| Disk Storage | Lined Cylinder | `lin-cyl` | Disk storage | `disk`, `lined-cylinder` |
|
||||||
|
@@ -360,7 +360,8 @@ gantt
|
|||||||
weekday monday
|
weekday monday
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Warning** > `millisecond` and `second` support was added in v10.3.0
|
> **Warning**
|
||||||
|
> `millisecond` and `second` support was added in v10.3.0
|
||||||
|
|
||||||
## Output in compact mode
|
## Output in compact mode
|
||||||
|
|
||||||
|
@@ -314,3 +314,22 @@ You can also refer the [implementation in the live editor](https://github.com/me
|
|||||||
cspell:locale en,en-gb
|
cspell:locale en,en-gb
|
||||||
cspell:ignore Buzan
|
cspell:ignore Buzan
|
||||||
--->
|
--->
|
||||||
|
|
||||||
|
## Layouts
|
||||||
|
|
||||||
|
Mermaid also supports a Tidy Tree layout for mindmaps.
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap is a long thing))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
```
|
||||||
|
|
||||||
|
Instructions to add and register tidy-tree layout are present in [Tidy Tree Configuration](/config/tidy-tree)
|
||||||
|
@@ -37,6 +37,11 @@ Drawing a pie chart is really simple in mermaid.
|
|||||||
- Followed by `:` colon as separator
|
- Followed by `:` colon as separator
|
||||||
- Followed by `positive numeric value` (supported up to two decimal places)
|
- Followed by `positive numeric value` (supported up to two decimal places)
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
> Pie chart values must be **positive numbers greater than zero**.\
|
||||||
|
> **Negative values are not allowed** and will result in an error.
|
||||||
|
|
||||||
\[pie] \[showData] (OPTIONAL)
|
\[pie] \[showData] (OPTIONAL)
|
||||||
\[title] \[titlevalue] (OPTIONAL)
|
\[title] \[titlevalue] (OPTIONAL)
|
||||||
"\[datakey1]" : \[dataValue1]
|
"\[datakey1]" : \[dataValue1]
|
||||||
|
@@ -23,7 +23,7 @@ config:
|
|||||||
sankey:
|
sankey:
|
||||||
showValues: false
|
showValues: false
|
||||||
---
|
---
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Agricultural 'waste',Bio-conversion,124.729
|
Agricultural 'waste',Bio-conversion,124.729
|
||||||
Bio-conversion,Liquid,0.597
|
Bio-conversion,Liquid,0.597
|
||||||
@@ -101,7 +101,7 @@ config:
|
|||||||
sankey:
|
sankey:
|
||||||
showValues: false
|
showValues: false
|
||||||
---
|
---
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Agricultural 'waste',Bio-conversion,124.729
|
Agricultural 'waste',Bio-conversion,124.729
|
||||||
Bio-conversion,Liquid,0.597
|
Bio-conversion,Liquid,0.597
|
||||||
@@ -175,7 +175,7 @@ Wind,Electricity grid,289.366
|
|||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
The idea behind syntax is that a user types `sankey-beta` keyword first, then pastes raw CSV below and get the result.
|
The idea behind syntax is that a user types `sankey` keyword first, then pastes raw CSV below and get the result.
|
||||||
|
|
||||||
It implements CSV standard as [described here](https://www.ietf.org/rfc/rfc4180.txt) with subtle **differences**:
|
It implements CSV standard as [described here](https://www.ietf.org/rfc/rfc4180.txt) with subtle **differences**:
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ It implements CSV standard as [described here](https://www.ietf.org/rfc/rfc4180.
|
|||||||
It is implied that 3 columns inside CSV should represent `source`, `target` and `value` accordingly:
|
It is implied that 3 columns inside CSV should represent `source`, `target` and `value` accordingly:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
%% source,target,value
|
%% source,target,value
|
||||||
Electricity grid,Over generation / exports,104.453
|
Electricity grid,Over generation / exports,104.453
|
||||||
@@ -196,7 +196,7 @@ Electricity grid,H2 conversion,27.14
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
%% source,target,value
|
%% source,target,value
|
||||||
Electricity grid,Over generation / exports,104.453
|
Electricity grid,Over generation / exports,104.453
|
||||||
@@ -209,7 +209,7 @@ Electricity grid,H2 conversion,27.14
|
|||||||
CSV does not support empty lines without comma delimiters by default. But you can add them if needed:
|
CSV does not support empty lines without comma delimiters by default. But you can add them if needed:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Bio-conversion,Losses,26.862
|
Bio-conversion,Losses,26.862
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ Bio-conversion,Gas,81.144
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Bio-conversion,Losses,26.862
|
Bio-conversion,Losses,26.862
|
||||||
|
|
||||||
@@ -233,14 +233,14 @@ Bio-conversion,Gas,81.144
|
|||||||
If you need to have a comma, wrap it in double quotes:
|
If you need to have a comma, wrap it in double quotes:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Pumped heat,"Heating and cooling, homes",193.026
|
Pumped heat,"Heating and cooling, homes",193.026
|
||||||
Pumped heat,"Heating and cooling, commercial",70.672
|
Pumped heat,"Heating and cooling, commercial",70.672
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Pumped heat,"Heating and cooling, homes",193.026
|
Pumped heat,"Heating and cooling, homes",193.026
|
||||||
Pumped heat,"Heating and cooling, commercial",70.672
|
Pumped heat,"Heating and cooling, commercial",70.672
|
||||||
@@ -251,14 +251,14 @@ Pumped heat,"Heating and cooling, commercial",70.672
|
|||||||
If you need to have double quote, put a pair of them inside quoted string:
|
If you need to have double quote, put a pair of them inside quoted string:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Pumped heat,"Heating and cooling, ""homes""",193.026
|
Pumped heat,"Heating and cooling, ""homes""",193.026
|
||||||
Pumped heat,"Heating and cooling, ""commercial""",70.672
|
Pumped heat,"Heating and cooling, ""commercial""",70.672
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
sankey-beta
|
sankey
|
||||||
|
|
||||||
Pumped heat,"Heating and cooling, ""homes""",193.026
|
Pumped heat,"Heating and cooling, ""homes""",193.026
|
||||||
Pumped heat,"Heating and cooling, ""commercial""",70.672
|
Pumped heat,"Heating and cooling, ""commercial""",70.672
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -22,7 +22,7 @@ xychart-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -40,7 +40,7 @@ xychart-beta
|
|||||||
The chart can be drawn horizontal or vertical, default value is vertical.
|
The chart can be drawn horizontal or vertical, default value is vertical.
|
||||||
|
|
||||||
```
|
```
|
||||||
xychart-beta horizontal
|
xychart horizontal
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ The title is a short description of the chart and it will always render on top o
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```
|
```
|
||||||
xychart-beta
|
xychart
|
||||||
title "This is a simple example"
|
title "This is a simple example"
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
@@ -98,10 +98,10 @@ A bar chart offers the capability to graphically depict bars.
|
|||||||
|
|
||||||
#### Simplest example
|
#### Simplest example
|
||||||
|
|
||||||
The only two things required are the chart name (`xychart-beta`) and one data set. So you will be able to draw a chart with a simple config like
|
The only two things required are the chart name (`xychart`) and one data set. So you will be able to draw a chart with a simple config like
|
||||||
|
|
||||||
```
|
```
|
||||||
xychart-beta
|
xychart
|
||||||
line [+1.3, .6, 2.4, -.34]
|
line [+1.3, .6, 2.4, -.34]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ config:
|
|||||||
xyChart:
|
xyChart:
|
||||||
titleColor: "#ff0000"
|
titleColor: "#ff0000"
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
@@ -195,7 +195,7 @@ config:
|
|||||||
xyChart:
|
xyChart:
|
||||||
titleColor: "#ff0000"
|
titleColor: "#ff0000"
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart
|
||||||
title "Sales Revenue"
|
title "Sales Revenue"
|
||||||
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
|
@@ -17,6 +17,7 @@ export default tseslint.config(
|
|||||||
...tseslint.configs.stylisticTypeChecked,
|
...tseslint.configs.stylisticTypeChecked,
|
||||||
{
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
|
'**/*.d.ts',
|
||||||
'**/dist/',
|
'**/dist/',
|
||||||
'**/node_modules/',
|
'**/node_modules/',
|
||||||
'.git/',
|
'.git/',
|
||||||
|
1
instructions.md
Normal file
1
instructions.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The instructions for Tidy-Tree layout can be found in [Tidy Tree Configuration](/config/tidy-tree)
|
@@ -69,4 +69,4 @@ mermaid.registerLayoutLoaders(elkLayouts);
|
|||||||
- `elk.mrtree`: Multi-root tree layout
|
- `elk.mrtree`: Multi-root tree layout
|
||||||
- `elk.sporeOverlap`: Spore overlap layout
|
- `elk.sporeOverlap`: Spore overlap layout
|
||||||
|
|
||||||
<!-- TODO: Add images for these layouts, as GitHub doesn't support natively -->
|
<!-- TODO: Add images for these layouts, as GitHub doesn't support natively. -->
|
||||||
|
9
packages/mermaid-layout-elk/src/find-common-ancestor.d.ts
vendored
Normal file
9
packages/mermaid-layout-elk/src/find-common-ancestor.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export interface TreeData {
|
||||||
|
parentById: Record<string, string>;
|
||||||
|
childrenById: Record<string, string[]>;
|
||||||
|
}
|
||||||
|
export declare const findCommonAncestor: (
|
||||||
|
id1: string,
|
||||||
|
id2: string,
|
||||||
|
{ parentById }: TreeData
|
||||||
|
) => string;
|
@@ -4,7 +4,8 @@ import type { InternalHelpers, LayoutData, RenderOptions, SVG, SVGGroup } from '
|
|||||||
import { type TreeData, findCommonAncestor } from './find-common-ancestor.js';
|
import { type TreeData, findCommonAncestor } from './find-common-ancestor.js';
|
||||||
|
|
||||||
type Node = LayoutData['nodes'][number];
|
type Node = LayoutData['nodes'][number];
|
||||||
|
// Used to calculate distances in order to avoid floating number rounding issues when comparing floating numbers
|
||||||
|
const epsilon = 0.0001;
|
||||||
interface LabelData {
|
interface LabelData {
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
@@ -13,11 +14,20 @@ interface LabelData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface NodeWithVertex extends Omit<Node, 'domId'> {
|
interface NodeWithVertex extends Omit<Node, 'domId'> {
|
||||||
children?: unknown[];
|
children?: LayoutData['nodes'];
|
||||||
labelData?: LabelData;
|
labelData?: LabelData;
|
||||||
domId?: Node['domId'] | SVGGroup | d3.Selection<SVGAElement, unknown, Element | null, unknown>;
|
domId?: Node['domId'] | SVGGroup | d3.Selection<SVGAElement, unknown, Element | null, unknown>;
|
||||||
}
|
}
|
||||||
|
interface Point {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
function distance(p1?: Point, p2?: Point): number {
|
||||||
|
if (!p1 || !p2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
||||||
|
}
|
||||||
export const render = async (
|
export const render = async (
|
||||||
data4Layout: LayoutData,
|
data4Layout: LayoutData,
|
||||||
svg: SVG,
|
svg: SVG,
|
||||||
@@ -51,15 +61,30 @@ export const render = async (
|
|||||||
|
|
||||||
// Add the element to the DOM
|
// Add the element to the DOM
|
||||||
if (!node.isGroup) {
|
if (!node.isGroup) {
|
||||||
|
// Create a clean node object for ELK with only the properties it expects
|
||||||
const child: NodeWithVertex = {
|
const child: NodeWithVertex = {
|
||||||
...node,
|
id: node.id,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
// Store the original node data for later use
|
||||||
|
label: node.label,
|
||||||
|
isGroup: node.isGroup,
|
||||||
|
shape: node.shape,
|
||||||
|
padding: node.padding,
|
||||||
|
cssClasses: node.cssClasses,
|
||||||
|
cssStyles: node.cssStyles,
|
||||||
|
look: node.look,
|
||||||
|
// Include parentId for subgraph processing
|
||||||
|
parentId: node.parentId,
|
||||||
};
|
};
|
||||||
graph.children.push(child);
|
graph.children.push(child);
|
||||||
nodeDb[node.id] = child;
|
nodeDb[node.id] = child;
|
||||||
|
|
||||||
const childNodeEl = await insertNode(nodeEl, node, { config, dir: node.dir });
|
const childNodeEl = await insertNode(nodeEl, node, { config, dir: node.dir });
|
||||||
const boundingBox = childNodeEl.node()!.getBBox();
|
const boundingBox = childNodeEl.node()!.getBBox();
|
||||||
|
// Store the domId separately for rendering, not in the ELK graph
|
||||||
child.domId = childNodeEl;
|
child.domId = childNodeEl;
|
||||||
|
child.calcIntersect = node.calcIntersect;
|
||||||
child.width = boundingBox.width;
|
child.width = boundingBox.width;
|
||||||
child.height = boundingBox.height;
|
child.height = boundingBox.height;
|
||||||
} else {
|
} else {
|
||||||
@@ -459,302 +484,6 @@ export const render = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function intersectLine(
|
|
||||||
p1: { y: number; x: number },
|
|
||||||
p2: { y: number; x: number },
|
|
||||||
q1: { x: any; y: any },
|
|
||||||
q2: { x: any; y: any }
|
|
||||||
) {
|
|
||||||
log.debug('UIO intersectLine', p1, p2, q1, q2);
|
|
||||||
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
|
|
||||||
// p7 and p473.
|
|
||||||
|
|
||||||
// let a1, a2, b1, b2, c1, c2;
|
|
||||||
// let r1, r2, r3, r4;
|
|
||||||
// let denom, offset, num;
|
|
||||||
// let x, y;
|
|
||||||
|
|
||||||
// Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x +
|
|
||||||
// b1 y + c1 = 0.
|
|
||||||
const a1 = p2.y - p1.y;
|
|
||||||
const b1 = p1.x - p2.x;
|
|
||||||
const c1 = p2.x * p1.y - p1.x * p2.y;
|
|
||||||
|
|
||||||
// Compute r3 and r4.
|
|
||||||
const r3 = a1 * q1.x + b1 * q1.y + c1;
|
|
||||||
const r4 = a1 * q2.x + b1 * q2.y + c1;
|
|
||||||
|
|
||||||
const epsilon = 1e-6;
|
|
||||||
|
|
||||||
// Check signs of r3 and r4. If both point 3 and point 4 lie on
|
|
||||||
// same side of line 1, the line segments do not intersect.
|
|
||||||
if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) {
|
|
||||||
return /*DON'T_INTERSECT*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0
|
|
||||||
const a2 = q2.y - q1.y;
|
|
||||||
const b2 = q1.x - q2.x;
|
|
||||||
const c2 = q2.x * q1.y - q1.x * q2.y;
|
|
||||||
|
|
||||||
// Compute r1 and r2
|
|
||||||
const r1 = a2 * p1.x + b2 * p1.y + c2;
|
|
||||||
const r2 = a2 * p2.x + b2 * p2.y + c2;
|
|
||||||
|
|
||||||
// Check signs of r1 and r2. If both point 1 and point 2 lie
|
|
||||||
// on same side of second line segment, the line segments do
|
|
||||||
// not intersect.
|
|
||||||
if (Math.abs(r1) < epsilon && Math.abs(r2) < epsilon && sameSign(r1, r2)) {
|
|
||||||
return /*DON'T_INTERSECT*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Line segments intersect: compute intersection point.
|
|
||||||
const denom = a1 * b2 - a2 * b1;
|
|
||||||
if (denom === 0) {
|
|
||||||
return /*COLLINEAR*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
const offset = Math.abs(denom / 2);
|
|
||||||
|
|
||||||
// The denom/2 is to get rounding instead of truncating. It
|
|
||||||
// is added or subtracted to the numerator, depending upon the
|
|
||||||
// sign of the numerator.
|
|
||||||
let num = b1 * c2 - b2 * c1;
|
|
||||||
const x = num < 0 ? (num - offset) / denom : (num + offset) / denom;
|
|
||||||
|
|
||||||
num = a2 * c1 - a1 * c2;
|
|
||||||
const y = num < 0 ? (num - offset) / denom : (num + offset) / denom;
|
|
||||||
|
|
||||||
return { x: x, y: y };
|
|
||||||
}
|
|
||||||
|
|
||||||
function sameSign(r1: number, r2: number) {
|
|
||||||
return r1 * r2 > 0;
|
|
||||||
}
|
|
||||||
const diamondIntersection = (
|
|
||||||
bounds: { x: any; y: any; width: any; height: any },
|
|
||||||
outsidePoint: { x: number; y: number },
|
|
||||||
insidePoint: any
|
|
||||||
) => {
|
|
||||||
const x1 = bounds.x;
|
|
||||||
const y1 = bounds.y;
|
|
||||||
|
|
||||||
const w = bounds.width; //+ bounds.padding;
|
|
||||||
const h = bounds.height; // + bounds.padding;
|
|
||||||
|
|
||||||
const polyPoints = [
|
|
||||||
{ x: x1, y: y1 - h / 2 },
|
|
||||||
{ x: x1 + w / 2, y: y1 },
|
|
||||||
{ x: x1, y: y1 + h / 2 },
|
|
||||||
{ x: x1 - w / 2, y: y1 },
|
|
||||||
];
|
|
||||||
log.debug(
|
|
||||||
`APA16 diamondIntersection calc abc89:
|
|
||||||
outsidePoint: ${JSON.stringify(outsidePoint)}
|
|
||||||
insidePoint : ${JSON.stringify(insidePoint)}
|
|
||||||
node-bounds : x:${bounds.x} y:${bounds.y} w:${bounds.width} h:${bounds.height}`,
|
|
||||||
JSON.stringify(polyPoints)
|
|
||||||
);
|
|
||||||
|
|
||||||
const intersections = [];
|
|
||||||
|
|
||||||
let minX = Number.POSITIVE_INFINITY;
|
|
||||||
let minY = Number.POSITIVE_INFINITY;
|
|
||||||
|
|
||||||
polyPoints.forEach(function (entry) {
|
|
||||||
minX = Math.min(minX, entry.x);
|
|
||||||
minY = Math.min(minY, entry.y);
|
|
||||||
});
|
|
||||||
|
|
||||||
const left = x1 - w / 2 - minX;
|
|
||||||
const top = y1 - h / 2 - minY;
|
|
||||||
|
|
||||||
for (let i = 0; i < polyPoints.length; i++) {
|
|
||||||
const p1 = polyPoints[i];
|
|
||||||
const p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0];
|
|
||||||
const intersect = intersectLine(
|
|
||||||
bounds,
|
|
||||||
outsidePoint,
|
|
||||||
{ x: left + p1.x, y: top + p1.y },
|
|
||||||
{ x: left + p2.x, y: top + p2.y }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (intersect) {
|
|
||||||
intersections.push(intersect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!intersections.length) {
|
|
||||||
return bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug('UIO intersections', intersections);
|
|
||||||
|
|
||||||
if (intersections.length > 1) {
|
|
||||||
// More intersections, find the one nearest to edge end point
|
|
||||||
intersections.sort(function (p, q) {
|
|
||||||
const pdx = p.x - outsidePoint.x;
|
|
||||||
const pdy = p.y - outsidePoint.y;
|
|
||||||
const distp = Math.sqrt(pdx * pdx + pdy * pdy);
|
|
||||||
|
|
||||||
const qdx = q.x - outsidePoint.x;
|
|
||||||
const qdy = q.y - outsidePoint.y;
|
|
||||||
const distq = Math.sqrt(qdx * qdx + qdy * qdy);
|
|
||||||
|
|
||||||
return distp < distq ? -1 : distp === distq ? 0 : 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return intersections[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
const intersection = (
|
|
||||||
node: { x: any; y: any; width: number; height: number },
|
|
||||||
outsidePoint: { x: number; y: number },
|
|
||||||
insidePoint: { x: number; y: number }
|
|
||||||
) => {
|
|
||||||
log.debug(`intersection calc abc89:
|
|
||||||
outsidePoint: ${JSON.stringify(outsidePoint)}
|
|
||||||
insidePoint : ${JSON.stringify(insidePoint)}
|
|
||||||
node : x:${node.x} y:${node.y} w:${node.width} h:${node.height}`);
|
|
||||||
const x = node.x;
|
|
||||||
const y = node.y;
|
|
||||||
|
|
||||||
const dx = Math.abs(x - insidePoint.x);
|
|
||||||
// const dy = Math.abs(y - insidePoint.y);
|
|
||||||
const w = node.width / 2;
|
|
||||||
let r = insidePoint.x < outsidePoint.x ? w - dx : w + dx;
|
|
||||||
const h = node.height / 2;
|
|
||||||
|
|
||||||
const Q = Math.abs(outsidePoint.y - insidePoint.y);
|
|
||||||
const R = Math.abs(outsidePoint.x - insidePoint.x);
|
|
||||||
|
|
||||||
if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) {
|
|
||||||
// Intersection is top or bottom of rect.
|
|
||||||
const q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y;
|
|
||||||
r = (R * q) / Q;
|
|
||||||
const res = {
|
|
||||||
x: insidePoint.x < outsidePoint.x ? insidePoint.x + r : insidePoint.x - R + r,
|
|
||||||
y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (r === 0) {
|
|
||||||
res.x = outsidePoint.x;
|
|
||||||
res.y = outsidePoint.y;
|
|
||||||
}
|
|
||||||
if (R === 0) {
|
|
||||||
res.x = outsidePoint.x;
|
|
||||||
}
|
|
||||||
if (Q === 0) {
|
|
||||||
res.y = outsidePoint.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug(`abc89 topp/bott calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res); // cspell: disable-line
|
|
||||||
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
// Intersection on sides of rect
|
|
||||||
if (insidePoint.x < outsidePoint.x) {
|
|
||||||
r = outsidePoint.x - w - x;
|
|
||||||
} else {
|
|
||||||
// r = outsidePoint.x - w - x;
|
|
||||||
r = x - w - outsidePoint.x;
|
|
||||||
}
|
|
||||||
const q = (Q * r) / R;
|
|
||||||
// OK let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : insidePoint.x + dx - w;
|
|
||||||
// OK let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : outsidePoint.x + r;
|
|
||||||
let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : insidePoint.x - R + r;
|
|
||||||
// let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : outsidePoint.x + r;
|
|
||||||
let _y = insidePoint.y < outsidePoint.y ? insidePoint.y + q : insidePoint.y - q;
|
|
||||||
log.debug(`sides calc abc89, Q ${Q}, q ${q}, R ${R}, r ${r}`, { _x, _y });
|
|
||||||
if (r === 0) {
|
|
||||||
_x = outsidePoint.x;
|
|
||||||
_y = outsidePoint.y;
|
|
||||||
}
|
|
||||||
if (R === 0) {
|
|
||||||
_x = outsidePoint.x;
|
|
||||||
}
|
|
||||||
if (Q === 0) {
|
|
||||||
_y = outsidePoint.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { x: _x, y: _y };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const outsideNode = (
|
|
||||||
node: { x: any; y: any; width: number; height: number },
|
|
||||||
point: { x: number; y: number }
|
|
||||||
) => {
|
|
||||||
const x = node.x;
|
|
||||||
const y = node.y;
|
|
||||||
const dx = Math.abs(point.x - x);
|
|
||||||
const dy = Math.abs(point.y - y);
|
|
||||||
const w = node.width / 2;
|
|
||||||
const h = node.height / 2;
|
|
||||||
if (dx >= w || dy >= h) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* This function will page a path and node where the last point(s) in the path is inside the node
|
|
||||||
* and return an update path ending by the border of the node.
|
|
||||||
*/
|
|
||||||
const cutPathAtIntersect = (
|
|
||||||
_points: any[],
|
|
||||||
bounds: { x: any; y: any; width: any; height: any; padding: any },
|
|
||||||
isDiamond: boolean
|
|
||||||
) => {
|
|
||||||
log.debug('APA18 cutPathAtIntersect Points:', _points, 'node:', bounds, 'isDiamond', isDiamond);
|
|
||||||
const points: any[] = [];
|
|
||||||
let lastPointOutside = _points[0];
|
|
||||||
let isInside = false;
|
|
||||||
_points.forEach((point: any) => {
|
|
||||||
// check if point is inside the boundary rect
|
|
||||||
if (!outsideNode(bounds, point) && !isInside) {
|
|
||||||
// First point inside the rect found
|
|
||||||
// Calc the intersection coord between the point and the last point outside the rect
|
|
||||||
let inter;
|
|
||||||
|
|
||||||
if (isDiamond) {
|
|
||||||
const inter2 = diamondIntersection(bounds, lastPointOutside, point);
|
|
||||||
const distance = Math.sqrt(
|
|
||||||
(lastPointOutside.x - inter2.x) ** 2 + (lastPointOutside.y - inter2.y) ** 2
|
|
||||||
);
|
|
||||||
if (distance > 1) {
|
|
||||||
inter = inter2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!inter) {
|
|
||||||
inter = intersection(bounds, lastPointOutside, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check case where the intersection is the same as the last point
|
|
||||||
let pointPresent = false;
|
|
||||||
points.forEach((p) => {
|
|
||||||
pointPresent = pointPresent || (p.x === inter.x && p.y === inter.y);
|
|
||||||
});
|
|
||||||
// if (!pointPresent) {
|
|
||||||
if (!points.some((e) => e.x === inter.x && e.y === inter.y)) {
|
|
||||||
points.push(inter);
|
|
||||||
} else {
|
|
||||||
log.debug('abc88 no intersect', inter, points);
|
|
||||||
}
|
|
||||||
// points.push(inter);
|
|
||||||
isInside = true;
|
|
||||||
} else {
|
|
||||||
// Outside
|
|
||||||
log.debug('abc88 outside', point, lastPointOutside, points);
|
|
||||||
lastPointOutside = point;
|
|
||||||
// points.push(point);
|
|
||||||
if (!isInside) {
|
|
||||||
points.push(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return points;
|
|
||||||
};
|
|
||||||
|
|
||||||
// @ts-ignore - ELK is not typed
|
// @ts-ignore - ELK is not typed
|
||||||
const elk = new ELK();
|
const elk = new ELK();
|
||||||
const element = svg.select('g');
|
const element = svg.select('g');
|
||||||
@@ -866,11 +595,16 @@ export const render = async (
|
|||||||
delete node.height;
|
delete node.height;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
elkGraph.edges.forEach((edge: any) => {
|
log.debug('APA01 processing edges, count:', elkGraph.edges.length);
|
||||||
|
elkGraph.edges.forEach((edge: any, index: number) => {
|
||||||
|
log.debug('APA01 processing edge', index, ':', edge);
|
||||||
const source = edge.sources[0];
|
const source = edge.sources[0];
|
||||||
const target = edge.targets[0];
|
const target = edge.targets[0];
|
||||||
|
log.debug('APA01 source:', source, 'target:', target);
|
||||||
|
log.debug('APA01 nodeDb[source]:', nodeDb[source]);
|
||||||
|
log.debug('APA01 nodeDb[target]:', nodeDb[target]);
|
||||||
|
|
||||||
if (nodeDb[source].parentId !== nodeDb[target].parentId) {
|
if (nodeDb[source] && nodeDb[target] && nodeDb[source].parentId !== nodeDb[target].parentId) {
|
||||||
const ancestorId = findCommonAncestor(source, target, parentLookupDb);
|
const ancestorId = findCommonAncestor(source, target, parentLookupDb);
|
||||||
// an edge that breaks a subgraph has been identified, set configuration accordingly
|
// an edge that breaks a subgraph has been identified, set configuration accordingly
|
||||||
setIncludeChildrenPolicy(source, ancestorId);
|
setIncludeChildrenPolicy(source, ancestorId);
|
||||||
@@ -878,7 +612,37 @@ export const render = async (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const g = await elk.layout(elkGraph);
|
log.debug('APA01 before');
|
||||||
|
log.debug('APA01 elkGraph structure:', JSON.stringify(elkGraph, null, 2));
|
||||||
|
log.debug('APA01 elkGraph.children length:', elkGraph.children?.length);
|
||||||
|
log.debug('APA01 elkGraph.edges length:', elkGraph.edges?.length);
|
||||||
|
|
||||||
|
// Validate that all edge references exist as nodes
|
||||||
|
elkGraph.edges?.forEach((edge: any, index: number) => {
|
||||||
|
log.debug(`APA01 validating edge ${index}:`, edge);
|
||||||
|
if (edge.sources) {
|
||||||
|
edge.sources.forEach((sourceId: any) => {
|
||||||
|
const sourceExists = elkGraph.children?.some((child: any) => child.id === sourceId);
|
||||||
|
log.debug(`APA01 source ${sourceId} exists:`, sourceExists);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (edge.targets) {
|
||||||
|
edge.targets.forEach((targetId: any) => {
|
||||||
|
const targetExists = elkGraph.children?.some((child: any) => child.id === targetId);
|
||||||
|
log.debug(`APA01 target ${targetId} exists:`, targetExists);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let g;
|
||||||
|
try {
|
||||||
|
g = await elk.layout(elkGraph);
|
||||||
|
log.debug('APA01 after - success');
|
||||||
|
log.debug('APA01 layout result:', JSON.stringify(g, null, 2));
|
||||||
|
} catch (error) {
|
||||||
|
log.error('APA01 ELK layout error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
// debugger;
|
// debugger;
|
||||||
await drawNodes(0, 0, g.children, svg, subGraphsEl, 0);
|
await drawNodes(0, 0, g.children, svg, subGraphsEl, 0);
|
||||||
@@ -966,43 +730,38 @@ export const render = async (
|
|||||||
startNode.innerHTML
|
startNode.innerHTML
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (startNode.shape === 'diamond' || startNode.shape === 'diam') {
|
|
||||||
edge.points.unshift({
|
|
||||||
x: startNode.offset.posX + startNode.width / 2,
|
|
||||||
y: startNode.offset.posY + startNode.height / 2,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (endNode.shape === 'diamond' || endNode.shape === 'diam') {
|
|
||||||
edge.points.push({
|
|
||||||
x: endNode.offset.posX + endNode.width / 2,
|
|
||||||
y: endNode.offset.posY + endNode.height / 2,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
edge.points = cutPathAtIntersect(
|
if (startNode.calcIntersect) {
|
||||||
edge.points.reverse(),
|
const intersection = startNode.calcIntersect(
|
||||||
{
|
{
|
||||||
x: startNode.offset.posX + startNode.width / 2,
|
x: startNode.offset.posX + startNode.width / 2,
|
||||||
y: startNode.offset.posY + startNode.height / 2,
|
y: startNode.offset.posY + startNode.height / 2,
|
||||||
width: sw,
|
width: startNode.width,
|
||||||
height: startNode.height,
|
height: startNode.height,
|
||||||
padding: startNode.padding,
|
|
||||||
},
|
},
|
||||||
startNode.shape === 'diamond' || startNode.shape === 'diam'
|
edge.points[0]
|
||||||
).reverse();
|
);
|
||||||
|
|
||||||
edge.points = cutPathAtIntersect(
|
if (distance(intersection, edge.points[0]) > epsilon) {
|
||||||
edge.points,
|
edge.points.unshift(intersection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (endNode.calcIntersect) {
|
||||||
|
const intersection = endNode.calcIntersect(
|
||||||
{
|
{
|
||||||
x: endNode.offset.posX + endNode.width / 2,
|
x: endNode.offset.posX + endNode.width / 2,
|
||||||
y: endNode.offset.posY + endNode.height / 2,
|
y: endNode.offset.posY + endNode.height / 2,
|
||||||
width: ew,
|
width: endNode.width,
|
||||||
height: endNode.height,
|
height: endNode.height,
|
||||||
padding: endNode.padding,
|
|
||||||
},
|
},
|
||||||
endNode.shape === 'diamond' || endNode.shape === 'diam'
|
edge.points[edge.points.length - 1]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (distance(intersection, edge.points[edge.points.length - 1]) > epsilon) {
|
||||||
|
edge.points.push(intersection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const paths = insertEdge(
|
const paths = insertEdge(
|
||||||
edgesEl,
|
edgesEl,
|
||||||
edge,
|
edge,
|
||||||
@@ -1012,7 +771,6 @@ export const render = async (
|
|||||||
endNode,
|
endNode,
|
||||||
data4Layout.diagramId
|
data4Layout.diagramId
|
||||||
);
|
);
|
||||||
log.info('APA12 edge points after insert', JSON.stringify(edge.points));
|
|
||||||
|
|
||||||
edge.x = edge.labels[0].x + offset.x + edge.labels[0].width / 2;
|
edge.x = edge.labels[0].x + offset.x + edge.labels[0].width / 2;
|
||||||
edge.y = edge.labels[0].y + offset.y + edge.labels[0].height / 2;
|
edge.y = edge.labels[0].y + offset.y + edge.labels[0].height / 2;
|
||||||
|
@@ -5,6 +5,6 @@
|
|||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"types": ["vitest/importMeta", "vitest/globals"]
|
"types": ["vitest/importMeta", "vitest/globals"]
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*.ts"],
|
"include": ["./src/**/*.ts", "./src/**/*.d.ts"],
|
||||||
"typeRoots": ["./src/types"]
|
"typeRoots": ["./src/types"]
|
||||||
}
|
}
|
||||||
|
59
packages/mermaid-layout-tidy-tree/README.md
Normal file
59
packages/mermaid-layout-tidy-tree/README.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# @mermaid-js/layout-tidy-tree
|
||||||
|
|
||||||
|
This package provides a bidirectional tidy tree layout engine for Mermaid based on the non-layered-tidy-tree-layout algorithm.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The Tidy Tree Layout engine will not be available in all providers that support mermaid by default.
|
||||||
|
> The websites will have to install the @mermaid-js/layout-tidy-tree package to use the Tidy Tree layout engine.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
config:
|
||||||
|
layout: tidy-tree
|
||||||
|
---
|
||||||
|
mindmap
|
||||||
|
root((mindmap))
|
||||||
|
A
|
||||||
|
B
|
||||||
|
```
|
||||||
|
|
||||||
|
### With bundlers
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @mermaid-js/layout-tidy-tree
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import mermaid from 'mermaid';
|
||||||
|
import tidyTreeLayouts from '@mermaid-js/layout-tidy-tree';
|
||||||
|
|
||||||
|
mermaid.registerLayoutLoaders(tidyTreeLayouts);
|
||||||
|
```
|
||||||
|
|
||||||
|
### With CDN
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
||||||
|
import tidyTreeLayouts from 'https://cdn.jsdelivr.net/npm/@mermaid-js/layout-tidy-tree@0/dist/mermaid-layout-tidy-tree.esm.min.mjs';
|
||||||
|
|
||||||
|
mermaid.registerLayoutLoaders(tidyTreeLayouts);
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tidy Tree Layout Overview
|
||||||
|
|
||||||
|
tidy-tree: The bidirectional tidy tree layout
|
||||||
|
|
||||||
|
The bidirectional tidy tree layout algorithm creates two separate trees that grow horizontally in opposite directions from a central root node:
|
||||||
|
Left tree: grows horizontally to the left (children alternate: 1st, 3rd, 5th...)
|
||||||
|
Right tree: grows horizontally to the right (children alternate: 2nd, 4th, 6th...)
|
||||||
|
|
||||||
|
This creates a balanced, symmetric layout that is ideal for mindmaps, organizational charts, and other tree-based diagrams.
|
||||||
|
|
||||||
|
Layout Structure:
|
||||||
|
[Child 3] ← [Child 1] ← [Root] → [Child 2] → [Child 4]
|
||||||
|
↓ ↓ ↓ ↓
|
||||||
|
[GrandChild] [GrandChild] [GrandChild] [GrandChild]
|
46
packages/mermaid-layout-tidy-tree/package.json
Normal file
46
packages/mermaid-layout-tidy-tree/package.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"name": "@mermaid-js/layout-tidy-tree",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Tidy-tree layout engine for mermaid",
|
||||||
|
"module": "dist/mermaid-layout-tidy-tree.core.mjs",
|
||||||
|
"types": "dist/layouts.d.ts",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./dist/mermaid-layout-tidy-tree.core.mjs",
|
||||||
|
"types": "./dist/layouts.d.ts"
|
||||||
|
},
|
||||||
|
"./": "./"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"diagram",
|
||||||
|
"markdown",
|
||||||
|
"tidy-tree",
|
||||||
|
"mermaid",
|
||||||
|
"layout"
|
||||||
|
],
|
||||||
|
"scripts": {},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/mermaid-js/mermaid"
|
||||||
|
},
|
||||||
|
"contributors": [
|
||||||
|
"Knut Sveidqvist",
|
||||||
|
"Sidharth Vinod"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"d3": "^7.9.0",
|
||||||
|
"non-layered-tidy-tree-layout": "^2.0.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/d3": "^7.4.3",
|
||||||
|
"mermaid": "workspace:^"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"mermaid": "^11.0.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
50
packages/mermaid-layout-tidy-tree/src/index.ts
Normal file
50
packages/mermaid-layout-tidy-tree/src/index.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Bidirectional Tidy-Tree Layout Algorithm for Generic Diagrams
|
||||||
|
*
|
||||||
|
* This module provides a layout algorithm implementation using the
|
||||||
|
* non-layered-tidy-tree-layout algorithm for positioning nodes and edges
|
||||||
|
* in tree structures with a bidirectional approach.
|
||||||
|
*
|
||||||
|
* The algorithm creates two separate trees that grow horizontally in opposite
|
||||||
|
* directions from a central root node:
|
||||||
|
* - Left tree: grows horizontally to the left (children alternate: 1st, 3rd, 5th...)
|
||||||
|
* - Right tree: grows horizontally to the right (children alternate: 2nd, 4th, 6th...)
|
||||||
|
*
|
||||||
|
* This creates a balanced, symmetric layout that is ideal for mindmaps,
|
||||||
|
* organizational charts, and other tree-based diagrams.
|
||||||
|
*
|
||||||
|
* The algorithm follows the unified rendering pattern and can be used
|
||||||
|
* by any diagram type that provides compatible LayoutData.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render function for the bidirectional tidy-tree layout algorithm
|
||||||
|
*
|
||||||
|
* This function follows the unified rendering pattern used by all layout algorithms.
|
||||||
|
* It takes LayoutData, inserts nodes into DOM, runs the bidirectional tidy-tree layout algorithm,
|
||||||
|
* and renders the positioned elements to the SVG.
|
||||||
|
*
|
||||||
|
* Features:
|
||||||
|
* - Alternates root children between left and right trees
|
||||||
|
* - Left tree grows horizontally to the left (rotated 90° counterclockwise)
|
||||||
|
* - Right tree grows horizontally to the right (rotated 90° clockwise)
|
||||||
|
* - Uses tidy-tree algorithm for optimal spacing within each tree
|
||||||
|
* - Creates symmetric, balanced layouts
|
||||||
|
* - Maintains proper edge connections between all nodes
|
||||||
|
*
|
||||||
|
* Layout Structure:
|
||||||
|
* ```
|
||||||
|
* [Child 3] ← [Child 1] ← [Root] → [Child 2] → [Child 4]
|
||||||
|
* ↓ ↓ ↓ ↓
|
||||||
|
* [GrandChild] [GrandChild] [GrandChild] [GrandChild]
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param layoutData - Layout data containing nodes, edges, and configuration
|
||||||
|
* @param svg - SVG element to render to
|
||||||
|
* @param helpers - Internal helper functions for rendering
|
||||||
|
* @param options - Rendering options
|
||||||
|
*/
|
||||||
|
export { default } from './layouts.js';
|
||||||
|
export * from './types.js';
|
||||||
|
export * from './layout.js';
|
||||||
|
export { render } from './render.js';
|
410
packages/mermaid-layout-tidy-tree/src/layout.test.ts
Normal file
410
packages/mermaid-layout-tidy-tree/src/layout.test.ts
Normal file
@@ -0,0 +1,410 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
|
|
||||||
|
// Mock non-layered-tidy-tree-layout
|
||||||
|
vi.mock('non-layered-tidy-tree-layout', () => ({
|
||||||
|
BoundingBox: vi.fn().mockImplementation(() => ({})),
|
||||||
|
Layout: vi.fn().mockImplementation(() => ({
|
||||||
|
layout: vi.fn().mockImplementation((treeData) => {
|
||||||
|
const result = { ...treeData };
|
||||||
|
|
||||||
|
if (result.id?.toString().startsWith('virtual-root')) {
|
||||||
|
result.x = 0;
|
||||||
|
result.y = 0;
|
||||||
|
} else {
|
||||||
|
result.x = 100;
|
||||||
|
result.y = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.children) {
|
||||||
|
result.children.forEach((child: any, index: number) => {
|
||||||
|
child.x = 50 + index * 100;
|
||||||
|
child.y = 100;
|
||||||
|
|
||||||
|
if (child.children) {
|
||||||
|
child.children.forEach((grandchild: any, gIndex: number) => {
|
||||||
|
grandchild.x = 25 + gIndex * 50;
|
||||||
|
grandchild.y = 200;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
result,
|
||||||
|
boundingBox: {
|
||||||
|
left: 0,
|
||||||
|
right: 200,
|
||||||
|
top: 0,
|
||||||
|
bottom: 250,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { executeTidyTreeLayout, validateLayoutData } from './layout.js';
|
||||||
|
import type { LayoutResult } from './types.js';
|
||||||
|
import type { LayoutData, MermaidConfig } from 'mermaid';
|
||||||
|
|
||||||
|
describe('Tidy-Tree Layout Algorithm', () => {
|
||||||
|
let mockConfig: MermaidConfig;
|
||||||
|
let mockLayoutData: LayoutData;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockConfig = {
|
||||||
|
theme: 'default',
|
||||||
|
} as MermaidConfig;
|
||||||
|
|
||||||
|
mockLayoutData = {
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
id: 'root',
|
||||||
|
label: 'Root',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect',
|
||||||
|
width: 100,
|
||||||
|
height: 50,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'child1',
|
||||||
|
label: 'Child 1',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect',
|
||||||
|
width: 80,
|
||||||
|
height: 40,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'child2',
|
||||||
|
label: 'Child 2',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect',
|
||||||
|
width: 80,
|
||||||
|
height: 40,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'child3',
|
||||||
|
label: 'Child 3',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect',
|
||||||
|
width: 80,
|
||||||
|
height: 40,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'child4',
|
||||||
|
label: 'Child 4',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect',
|
||||||
|
width: 80,
|
||||||
|
height: 40,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
id: 'root_child1',
|
||||||
|
start: 'root',
|
||||||
|
end: 'child1',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'root_child2',
|
||||||
|
start: 'root',
|
||||||
|
end: 'child2',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'root_child3',
|
||||||
|
start: 'root',
|
||||||
|
end: 'child3',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'root_child4',
|
||||||
|
start: 'root',
|
||||||
|
end: 'child4',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
config: mockConfig,
|
||||||
|
direction: 'TB',
|
||||||
|
type: 'test',
|
||||||
|
diagramId: 'test-diagram',
|
||||||
|
markers: [],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('validateLayoutData', () => {
|
||||||
|
it('should validate correct layout data', () => {
|
||||||
|
expect(() => validateLayoutData(mockLayoutData)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error for missing data', () => {
|
||||||
|
expect(() => validateLayoutData(null as any)).toThrow('Layout data is required');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error for missing config', () => {
|
||||||
|
const invalidData = { ...mockLayoutData, config: null as any };
|
||||||
|
expect(() => validateLayoutData(invalidData)).toThrow('Configuration is required');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error for invalid nodes array', () => {
|
||||||
|
const invalidData = { ...mockLayoutData, nodes: null as any };
|
||||||
|
expect(() => validateLayoutData(invalidData)).toThrow('Nodes array is required');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error for invalid edges array', () => {
|
||||||
|
const invalidData = { ...mockLayoutData, edges: null as any };
|
||||||
|
expect(() => validateLayoutData(invalidData)).toThrow('Edges array is required');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('executeTidyTreeLayout function', () => {
|
||||||
|
it('should execute layout algorithm successfully', async () => {
|
||||||
|
const result: LayoutResult = await executeTidyTreeLayout(mockLayoutData, mockConfig);
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result.nodes).toBeDefined();
|
||||||
|
expect(result.edges).toBeDefined();
|
||||||
|
expect(Array.isArray(result.nodes)).toBe(true);
|
||||||
|
expect(Array.isArray(result.edges)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return positioned nodes with coordinates', async () => {
|
||||||
|
const result: LayoutResult = await executeTidyTreeLayout(mockLayoutData, mockConfig);
|
||||||
|
|
||||||
|
expect(result.nodes.length).toBeGreaterThan(0);
|
||||||
|
result.nodes.forEach((node) => {
|
||||||
|
expect(node.x).toBeDefined();
|
||||||
|
expect(node.y).toBeDefined();
|
||||||
|
expect(typeof node.x).toBe('number');
|
||||||
|
expect(typeof node.y).toBe('number');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return positioned edges with coordinates', async () => {
|
||||||
|
const result: LayoutResult = await executeTidyTreeLayout(mockLayoutData, mockConfig);
|
||||||
|
|
||||||
|
expect(result.edges.length).toBeGreaterThan(0);
|
||||||
|
result.edges.forEach((edge) => {
|
||||||
|
expect(edge.startX).toBeDefined();
|
||||||
|
expect(edge.startY).toBeDefined();
|
||||||
|
expect(edge.midX).toBeDefined();
|
||||||
|
expect(edge.midY).toBeDefined();
|
||||||
|
expect(edge.endX).toBeDefined();
|
||||||
|
expect(edge.endY).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty layout data gracefully', async () => {
|
||||||
|
const emptyData: LayoutData = {
|
||||||
|
...mockLayoutData,
|
||||||
|
nodes: [],
|
||||||
|
edges: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
await expect(executeTidyTreeLayout(emptyData, mockConfig)).rejects.toThrow(
|
||||||
|
'No nodes found in layout data'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error for missing nodes', async () => {
|
||||||
|
const invalidData = { ...mockLayoutData, nodes: [] };
|
||||||
|
|
||||||
|
await expect(executeTidyTreeLayout(invalidData, mockConfig)).rejects.toThrow(
|
||||||
|
'No nodes found in layout data'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty edges (single node tree)', async () => {
|
||||||
|
const singleNodeData = {
|
||||||
|
...mockLayoutData,
|
||||||
|
edges: [],
|
||||||
|
nodes: [mockLayoutData.nodes[0]],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await executeTidyTreeLayout(singleNodeData, mockConfig);
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result.nodes).toHaveLength(1);
|
||||||
|
expect(result.edges).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create bidirectional dual-tree layout with alternating left/right children', async () => {
|
||||||
|
const result = await executeTidyTreeLayout(mockLayoutData, mockConfig);
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result.nodes).toHaveLength(5);
|
||||||
|
|
||||||
|
const rootNode = result.nodes.find((node) => node.id === 'root');
|
||||||
|
expect(rootNode).toBeDefined();
|
||||||
|
expect(rootNode!.x).toBe(0);
|
||||||
|
expect(rootNode!.y).toBe(20);
|
||||||
|
|
||||||
|
const child1 = result.nodes.find((node) => node.id === 'child1');
|
||||||
|
const child2 = result.nodes.find((node) => node.id === 'child2');
|
||||||
|
const child3 = result.nodes.find((node) => node.id === 'child3');
|
||||||
|
const child4 = result.nodes.find((node) => node.id === 'child4');
|
||||||
|
|
||||||
|
expect(child1).toBeDefined();
|
||||||
|
expect(child2).toBeDefined();
|
||||||
|
expect(child3).toBeDefined();
|
||||||
|
expect(child4).toBeDefined();
|
||||||
|
|
||||||
|
expect(child1!.x).toBeLessThan(rootNode!.x);
|
||||||
|
expect(child2!.x).toBeGreaterThan(rootNode!.x);
|
||||||
|
expect(child3!.x).toBeLessThan(rootNode!.x);
|
||||||
|
expect(child4!.x).toBeGreaterThan(rootNode!.x);
|
||||||
|
|
||||||
|
expect(child1!.x).toBeLessThan(-100);
|
||||||
|
expect(child3!.x).toBeLessThan(-100);
|
||||||
|
|
||||||
|
expect(child2!.x).toBeGreaterThan(100);
|
||||||
|
expect(child4!.x).toBeGreaterThan(100);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should correctly transpose coordinates to prevent high nodes from covering nodes above them', async () => {
|
||||||
|
const testData = {
|
||||||
|
...mockLayoutData,
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
id: 'root',
|
||||||
|
label: 'Root',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect' as const,
|
||||||
|
width: 100,
|
||||||
|
height: 50,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tall-child',
|
||||||
|
label: 'Tall Child',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect' as const,
|
||||||
|
width: 80,
|
||||||
|
height: 120,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'short-child',
|
||||||
|
label: 'Short Child',
|
||||||
|
isGroup: false,
|
||||||
|
shape: 'rect' as const,
|
||||||
|
width: 80,
|
||||||
|
height: 30,
|
||||||
|
padding: 10,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
cssClasses: '',
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
id: 'root_tall',
|
||||||
|
start: 'root',
|
||||||
|
end: 'tall-child',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'root_short',
|
||||||
|
start: 'root',
|
||||||
|
end: 'short-child',
|
||||||
|
type: 'edge',
|
||||||
|
classes: '',
|
||||||
|
style: [],
|
||||||
|
animate: false,
|
||||||
|
arrowTypeEnd: 'arrow_point',
|
||||||
|
arrowTypeStart: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await executeTidyTreeLayout(testData, mockConfig);
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
expect(result.nodes).toHaveLength(3);
|
||||||
|
|
||||||
|
const rootNode = result.nodes.find((node) => node.id === 'root');
|
||||||
|
const tallChild = result.nodes.find((node) => node.id === 'tall-child');
|
||||||
|
const shortChild = result.nodes.find((node) => node.id === 'short-child');
|
||||||
|
|
||||||
|
expect(rootNode).toBeDefined();
|
||||||
|
expect(tallChild).toBeDefined();
|
||||||
|
expect(shortChild).toBeDefined();
|
||||||
|
|
||||||
|
expect(tallChild!.x).not.toBe(shortChild!.x);
|
||||||
|
|
||||||
|
expect(tallChild!.width).toBe(80);
|
||||||
|
expect(tallChild!.height).toBe(120);
|
||||||
|
expect(shortChild!.width).toBe(80);
|
||||||
|
expect(shortChild!.height).toBe(30);
|
||||||
|
|
||||||
|
const yDifference = Math.abs(tallChild!.y - shortChild!.y);
|
||||||
|
expect(yDifference).toBeGreaterThanOrEqual(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
638
packages/mermaid-layout-tidy-tree/src/layout.ts
Normal file
638
packages/mermaid-layout-tidy-tree/src/layout.ts
Normal file
@@ -0,0 +1,638 @@
|
|||||||
|
import { BoundingBox, Layout } from 'non-layered-tidy-tree-layout';
|
||||||
|
import type { MermaidConfig, LayoutData } from 'mermaid';
|
||||||
|
import type {
|
||||||
|
LayoutResult,
|
||||||
|
TidyTreeNode,
|
||||||
|
PositionedNode,
|
||||||
|
PositionedEdge,
|
||||||
|
Node,
|
||||||
|
Edge,
|
||||||
|
} from './types.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the tidy-tree layout algorithm on generic layout data
|
||||||
|
*
|
||||||
|
* This function takes layout data and uses the non-layered-tidy-tree-layout
|
||||||
|
* algorithm to calculate optimal node positions for tree structures.
|
||||||
|
*
|
||||||
|
* @param data - The layout data containing nodes, edges, and configuration
|
||||||
|
* @param config - Mermaid configuration object
|
||||||
|
* @returns Promise resolving to layout result with positioned nodes and edges
|
||||||
|
*/
|
||||||
|
export function executeTidyTreeLayout(
|
||||||
|
data: LayoutData,
|
||||||
|
_config: MermaidConfig
|
||||||
|
): Promise<LayoutResult> {
|
||||||
|
let intersectionShift = 50;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
if (!data.nodes || !Array.isArray(data.nodes) || data.nodes.length === 0) {
|
||||||
|
throw new Error('No nodes found in layout data');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.edges || !Array.isArray(data.edges)) {
|
||||||
|
data.edges = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { leftTree, rightTree, rootNode } = convertToDualTreeFormat(data);
|
||||||
|
|
||||||
|
const gap = 20;
|
||||||
|
const bottomPadding = 40;
|
||||||
|
intersectionShift = 30;
|
||||||
|
|
||||||
|
const bb = new BoundingBox(gap, bottomPadding);
|
||||||
|
const layout = new Layout(bb);
|
||||||
|
|
||||||
|
let leftResult = null;
|
||||||
|
let rightResult = null;
|
||||||
|
let leftBoundingBox = null;
|
||||||
|
let rightBoundingBox = null;
|
||||||
|
|
||||||
|
if (leftTree) {
|
||||||
|
const leftLayoutResult = layout.layout(leftTree);
|
||||||
|
leftResult = leftLayoutResult.result;
|
||||||
|
leftBoundingBox = leftLayoutResult.boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightTree) {
|
||||||
|
const rightLayoutResult = layout.layout(rightTree);
|
||||||
|
rightResult = rightLayoutResult.result;
|
||||||
|
rightBoundingBox = rightLayoutResult.boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
const positionedNodes = combineAndPositionTrees(
|
||||||
|
rootNode,
|
||||||
|
leftResult,
|
||||||
|
rightResult,
|
||||||
|
leftBoundingBox,
|
||||||
|
rightBoundingBox,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
const positionedEdges = calculateEdgePositions(
|
||||||
|
data.edges,
|
||||||
|
positionedNodes,
|
||||||
|
intersectionShift
|
||||||
|
);
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
nodes: positionedNodes,
|
||||||
|
edges: positionedEdges,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert LayoutData to dual-tree format (left and right trees)
|
||||||
|
*
|
||||||
|
* This function builds two separate tree structures from the nodes and edges,
|
||||||
|
* alternating children between left and right trees.
|
||||||
|
*/
|
||||||
|
function convertToDualTreeFormat(data: LayoutData): {
|
||||||
|
leftTree: TidyTreeNode | null;
|
||||||
|
rightTree: TidyTreeNode | null;
|
||||||
|
rootNode: TidyTreeNode;
|
||||||
|
} {
|
||||||
|
const { nodes, edges } = data;
|
||||||
|
|
||||||
|
const nodeMap = new Map<string, Node>();
|
||||||
|
nodes.forEach((node) => nodeMap.set(node.id, node));
|
||||||
|
|
||||||
|
const children = new Map<string, string[]>();
|
||||||
|
const parents = new Map<string, string>();
|
||||||
|
|
||||||
|
edges.forEach((edge) => {
|
||||||
|
const parentId = edge.start;
|
||||||
|
const childId = edge.end;
|
||||||
|
|
||||||
|
if (parentId && childId) {
|
||||||
|
if (!children.has(parentId)) {
|
||||||
|
children.set(parentId, []);
|
||||||
|
}
|
||||||
|
children.get(parentId)!.push(childId);
|
||||||
|
parents.set(childId, parentId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const rootNodeData = nodes.find((node) => !parents.has(node.id));
|
||||||
|
if (!rootNodeData && nodes.length === 0) {
|
||||||
|
throw new Error('No nodes available to create tree');
|
||||||
|
}
|
||||||
|
|
||||||
|
const actualRoot = rootNodeData ?? nodes[0];
|
||||||
|
|
||||||
|
const rootNode: TidyTreeNode = {
|
||||||
|
id: actualRoot.id,
|
||||||
|
width: actualRoot.width ?? 100,
|
||||||
|
height: actualRoot.height ?? 50,
|
||||||
|
_originalNode: actualRoot,
|
||||||
|
};
|
||||||
|
|
||||||
|
const rootChildren = children.get(actualRoot.id) ?? [];
|
||||||
|
const leftChildren: string[] = [];
|
||||||
|
const rightChildren: string[] = [];
|
||||||
|
|
||||||
|
rootChildren.forEach((childId, index) => {
|
||||||
|
if (index % 2 === 0) {
|
||||||
|
leftChildren.push(childId);
|
||||||
|
} else {
|
||||||
|
rightChildren.push(childId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const leftTree = leftChildren.length > 0 ? buildSubTree(leftChildren, children, nodeMap) : null;
|
||||||
|
|
||||||
|
const rightTree =
|
||||||
|
rightChildren.length > 0 ? buildSubTree(rightChildren, children, nodeMap) : null;
|
||||||
|
|
||||||
|
return { leftTree, rightTree, rootNode };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a subtree from a list of root children
|
||||||
|
* For horizontal trees, we need to transpose width/height since the tree will be rotated 90°
|
||||||
|
*/
|
||||||
|
function buildSubTree(
|
||||||
|
rootChildren: string[],
|
||||||
|
children: Map<string, string[]>,
|
||||||
|
nodeMap: Map<string, Node>
|
||||||
|
): TidyTreeNode {
|
||||||
|
const virtualRoot: TidyTreeNode = {
|
||||||
|
id: `virtual-root-${Math.random()}`,
|
||||||
|
width: 1,
|
||||||
|
height: 1,
|
||||||
|
children: rootChildren
|
||||||
|
.map((childId) => nodeMap.get(childId))
|
||||||
|
.filter((child): child is Node => child !== undefined)
|
||||||
|
.map((child) => convertNodeToTidyTreeTransposed(child, children, nodeMap)),
|
||||||
|
};
|
||||||
|
|
||||||
|
return virtualRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively convert a node and its children to tidy-tree format
|
||||||
|
* This version transposes width/height for horizontal tree layout
|
||||||
|
*/
|
||||||
|
function convertNodeToTidyTreeTransposed(
|
||||||
|
node: Node,
|
||||||
|
children: Map<string, string[]>,
|
||||||
|
nodeMap: Map<string, Node>
|
||||||
|
): TidyTreeNode {
|
||||||
|
const childIds = children.get(node.id) ?? [];
|
||||||
|
const childNodes = childIds
|
||||||
|
.map((childId) => nodeMap.get(childId))
|
||||||
|
.filter((child): child is Node => child !== undefined)
|
||||||
|
.map((child) => convertNodeToTidyTreeTransposed(child, children, nodeMap));
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: node.id,
|
||||||
|
width: node.height ?? 50,
|
||||||
|
height: node.width ?? 100,
|
||||||
|
children: childNodes.length > 0 ? childNodes : undefined,
|
||||||
|
_originalNode: node,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Combine and position the left and right trees around the root node
|
||||||
|
* Creates a bidirectional layout where left tree grows left and right tree grows right
|
||||||
|
*/
|
||||||
|
function combineAndPositionTrees(
|
||||||
|
rootNode: TidyTreeNode,
|
||||||
|
leftResult: TidyTreeNode | null,
|
||||||
|
rightResult: TidyTreeNode | null,
|
||||||
|
_leftBoundingBox: any,
|
||||||
|
_rightBoundingBox: any,
|
||||||
|
_data: LayoutData
|
||||||
|
): PositionedNode[] {
|
||||||
|
const positionedNodes: PositionedNode[] = [];
|
||||||
|
|
||||||
|
const rootX = 0;
|
||||||
|
const rootY = 0;
|
||||||
|
|
||||||
|
const treeSpacing = rootNode.width / 2 + 30;
|
||||||
|
const leftTreeNodes: PositionedNode[] = [];
|
||||||
|
const rightTreeNodes: PositionedNode[] = [];
|
||||||
|
|
||||||
|
if (leftResult?.children) {
|
||||||
|
positionLeftTreeBidirectional(leftResult.children, leftTreeNodes, rootX - treeSpacing, rootY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightResult?.children) {
|
||||||
|
positionRightTreeBidirectional(
|
||||||
|
rightResult.children,
|
||||||
|
rightTreeNodes,
|
||||||
|
rootX + treeSpacing,
|
||||||
|
rootY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let leftTreeCenterY = 0;
|
||||||
|
let rightTreeCenterY = 0;
|
||||||
|
|
||||||
|
if (leftTreeNodes.length > 0) {
|
||||||
|
const leftTreeXPositions = [...new Set(leftTreeNodes.map((node) => node.x))].sort(
|
||||||
|
(a, b) => b - a
|
||||||
|
);
|
||||||
|
const firstLevelLeftX = leftTreeXPositions[0];
|
||||||
|
const firstLevelLeftNodes = leftTreeNodes.filter((node) => node.x === firstLevelLeftX);
|
||||||
|
|
||||||
|
if (firstLevelLeftNodes.length > 0) {
|
||||||
|
const leftMinY = Math.min(
|
||||||
|
...firstLevelLeftNodes.map((node) => node.y - (node.height ?? 50) / 2)
|
||||||
|
);
|
||||||
|
const leftMaxY = Math.max(
|
||||||
|
...firstLevelLeftNodes.map((node) => node.y + (node.height ?? 50) / 2)
|
||||||
|
);
|
||||||
|
leftTreeCenterY = (leftMinY + leftMaxY) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightTreeNodes.length > 0) {
|
||||||
|
const rightTreeXPositions = [...new Set(rightTreeNodes.map((node) => node.x))].sort(
|
||||||
|
(a, b) => a - b
|
||||||
|
);
|
||||||
|
const firstLevelRightX = rightTreeXPositions[0];
|
||||||
|
const firstLevelRightNodes = rightTreeNodes.filter((node) => node.x === firstLevelRightX);
|
||||||
|
|
||||||
|
if (firstLevelRightNodes.length > 0) {
|
||||||
|
const rightMinY = Math.min(
|
||||||
|
...firstLevelRightNodes.map((node) => node.y - (node.height ?? 50) / 2)
|
||||||
|
);
|
||||||
|
const rightMaxY = Math.max(
|
||||||
|
...firstLevelRightNodes.map((node) => node.y + (node.height ?? 50) / 2)
|
||||||
|
);
|
||||||
|
rightTreeCenterY = (rightMinY + rightMaxY) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftTreeOffset = -leftTreeCenterY;
|
||||||
|
const rightTreeOffset = -rightTreeCenterY;
|
||||||
|
|
||||||
|
positionedNodes.push({
|
||||||
|
id: String(rootNode.id),
|
||||||
|
x: rootX,
|
||||||
|
y: rootY + 20,
|
||||||
|
section: 'root',
|
||||||
|
width: rootNode._originalNode?.width ?? rootNode.width,
|
||||||
|
height: rootNode._originalNode?.height ?? rootNode.height,
|
||||||
|
originalNode: rootNode._originalNode,
|
||||||
|
});
|
||||||
|
|
||||||
|
const leftTreeNodesWithOffset = leftTreeNodes.map((node) => ({
|
||||||
|
id: node.id,
|
||||||
|
x: node.x - (node.width ?? 0) / 2,
|
||||||
|
y: node.y + leftTreeOffset + (node.height ?? 0) / 2,
|
||||||
|
section: 'left' as const,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
originalNode: node.originalNode,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const rightTreeNodesWithOffset = rightTreeNodes.map((node) => ({
|
||||||
|
id: node.id,
|
||||||
|
x: node.x + (node.width ?? 0) / 2,
|
||||||
|
y: node.y + rightTreeOffset + (node.height ?? 0) / 2,
|
||||||
|
section: 'right' as const,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
originalNode: node.originalNode,
|
||||||
|
}));
|
||||||
|
|
||||||
|
positionedNodes.push(...leftTreeNodesWithOffset);
|
||||||
|
positionedNodes.push(...rightTreeNodesWithOffset);
|
||||||
|
|
||||||
|
return positionedNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position nodes from the left tree in a bidirectional layout (grows to the left)
|
||||||
|
* Rotates the tree 90 degrees counterclockwise so it grows horizontally to the left
|
||||||
|
*/
|
||||||
|
function positionLeftTreeBidirectional(
|
||||||
|
nodes: TidyTreeNode[],
|
||||||
|
positionedNodes: PositionedNode[],
|
||||||
|
offsetX: number,
|
||||||
|
offsetY: number
|
||||||
|
): void {
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
const distanceFromRoot = node.y ?? 0;
|
||||||
|
const verticalPosition = node.x ?? 0;
|
||||||
|
|
||||||
|
const originalWidth = node._originalNode?.width ?? 100;
|
||||||
|
const originalHeight = node._originalNode?.height ?? 50;
|
||||||
|
|
||||||
|
const adjustedY = offsetY + verticalPosition;
|
||||||
|
|
||||||
|
positionedNodes.push({
|
||||||
|
id: String(node.id),
|
||||||
|
x: offsetX - distanceFromRoot,
|
||||||
|
y: adjustedY,
|
||||||
|
width: originalWidth,
|
||||||
|
height: originalHeight,
|
||||||
|
originalNode: node._originalNode,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (node.children) {
|
||||||
|
positionLeftTreeBidirectional(node.children, positionedNodes, offsetX, offsetY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position nodes from the right tree in a bidirectional layout (grows to the right)
|
||||||
|
* Rotates the tree 90 degrees clockwise so it grows horizontally to the right
|
||||||
|
*/
|
||||||
|
function positionRightTreeBidirectional(
|
||||||
|
nodes: TidyTreeNode[],
|
||||||
|
positionedNodes: PositionedNode[],
|
||||||
|
offsetX: number,
|
||||||
|
offsetY: number
|
||||||
|
): void {
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
const distanceFromRoot = node.y ?? 0;
|
||||||
|
const verticalPosition = node.x ?? 0;
|
||||||
|
|
||||||
|
const originalWidth = node._originalNode?.width ?? 100;
|
||||||
|
const originalHeight = node._originalNode?.height ?? 50;
|
||||||
|
|
||||||
|
const adjustedY = offsetY + verticalPosition;
|
||||||
|
|
||||||
|
positionedNodes.push({
|
||||||
|
id: String(node.id),
|
||||||
|
x: offsetX + distanceFromRoot,
|
||||||
|
y: adjustedY,
|
||||||
|
width: originalWidth,
|
||||||
|
height: originalHeight,
|
||||||
|
originalNode: node._originalNode,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (node.children) {
|
||||||
|
positionRightTreeBidirectional(node.children, positionedNodes, offsetX, offsetY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the intersection point of a line with a circle
|
||||||
|
* @param circle - Circle coordinates and radius
|
||||||
|
* @param lineStart - Starting point of the line
|
||||||
|
* @param lineEnd - Ending point of the line
|
||||||
|
* @returns The intersection point
|
||||||
|
*/
|
||||||
|
function computeCircleEdgeIntersection(
|
||||||
|
circle: { x: number; y: number; width: number; height: number },
|
||||||
|
lineStart: { x: number; y: number },
|
||||||
|
lineEnd: { x: number; y: number }
|
||||||
|
): { x: number; y: number } {
|
||||||
|
const radius = Math.min(circle.width, circle.height) / 2;
|
||||||
|
|
||||||
|
const dx = lineEnd.x - lineStart.x;
|
||||||
|
const dy = lineEnd.y - lineStart.y;
|
||||||
|
const length = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
if (length === 0) {
|
||||||
|
return lineStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nx = dx / length;
|
||||||
|
const ny = dy / length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: circle.x - nx * radius,
|
||||||
|
y: circle.y - ny * radius,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate intersection point of a line with a rectangle
|
||||||
|
* This is a simplified version that we'll use instead of importing from mermaid
|
||||||
|
*/
|
||||||
|
function intersection(
|
||||||
|
node: { x: number; y: number; width?: number; height?: number },
|
||||||
|
point1: { x: number; y: number },
|
||||||
|
point2: { x: number; y: number }
|
||||||
|
): { x: number; y: number } {
|
||||||
|
const nodeWidth = node.width ?? 100;
|
||||||
|
const nodeHeight = node.height ?? 50;
|
||||||
|
|
||||||
|
const centerX = node.x;
|
||||||
|
const centerY = node.y;
|
||||||
|
|
||||||
|
const dx = point2.x - point1.x;
|
||||||
|
const dy = point2.y - point1.y;
|
||||||
|
|
||||||
|
if (dx === 0 && dy === 0) {
|
||||||
|
return { x: centerX, y: centerY };
|
||||||
|
}
|
||||||
|
|
||||||
|
const halfWidth = nodeWidth / 2;
|
||||||
|
const halfHeight = nodeHeight / 2;
|
||||||
|
|
||||||
|
let intersectionX = centerX;
|
||||||
|
let intersectionY = centerY;
|
||||||
|
|
||||||
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
|
if (dx > 0) {
|
||||||
|
intersectionX = centerX + halfWidth;
|
||||||
|
intersectionY = centerY + (halfWidth * dy) / dx;
|
||||||
|
} else {
|
||||||
|
intersectionX = centerX - halfWidth;
|
||||||
|
intersectionY = centerY - (halfWidth * dy) / dx;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dy > 0) {
|
||||||
|
intersectionY = centerY + halfHeight;
|
||||||
|
intersectionX = centerX + (halfHeight * dx) / dy;
|
||||||
|
} else {
|
||||||
|
intersectionY = centerY - halfHeight;
|
||||||
|
intersectionX = centerX - (halfHeight * dx) / dy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { x: intersectionX, y: intersectionY };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate edge positions based on positioned nodes
|
||||||
|
* Now includes tree membership and node dimensions for precise edge calculations
|
||||||
|
* Edges now stop at shape boundaries instead of extending to centers
|
||||||
|
*/
|
||||||
|
function calculateEdgePositions(
|
||||||
|
edges: Edge[],
|
||||||
|
positionedNodes: PositionedNode[],
|
||||||
|
intersectionShift: number
|
||||||
|
): PositionedEdge[] {
|
||||||
|
const nodeInfo = new Map<string, PositionedNode>();
|
||||||
|
positionedNodes.forEach((node) => {
|
||||||
|
nodeInfo.set(node.id, node);
|
||||||
|
});
|
||||||
|
|
||||||
|
return edges.map((edge) => {
|
||||||
|
const sourceNode = nodeInfo.get(edge.start ?? '');
|
||||||
|
const targetNode = nodeInfo.get(edge.end ?? '');
|
||||||
|
|
||||||
|
if (!sourceNode || !targetNode) {
|
||||||
|
return {
|
||||||
|
id: edge.id,
|
||||||
|
source: edge.start ?? '',
|
||||||
|
target: edge.end ?? '',
|
||||||
|
startX: 0,
|
||||||
|
startY: 0,
|
||||||
|
midX: 0,
|
||||||
|
midY: 0,
|
||||||
|
endX: 0,
|
||||||
|
endY: 0,
|
||||||
|
points: [{ x: 0, y: 0 }],
|
||||||
|
sourceSection: undefined,
|
||||||
|
targetSection: undefined,
|
||||||
|
sourceWidth: undefined,
|
||||||
|
sourceHeight: undefined,
|
||||||
|
targetWidth: undefined,
|
||||||
|
targetHeight: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceCenter = { x: sourceNode.x, y: sourceNode.y };
|
||||||
|
const targetCenter = { x: targetNode.x, y: targetNode.y };
|
||||||
|
|
||||||
|
const isSourceRound = ['circle', 'cloud', 'bang'].includes(
|
||||||
|
sourceNode.originalNode?.shape ?? ''
|
||||||
|
);
|
||||||
|
const isTargetRound = ['circle', 'cloud', 'bang'].includes(
|
||||||
|
targetNode.originalNode?.shape ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
|
let startPos = isSourceRound
|
||||||
|
? computeCircleEdgeIntersection(
|
||||||
|
{
|
||||||
|
x: sourceNode.x,
|
||||||
|
y: sourceNode.y,
|
||||||
|
width: sourceNode.width ?? 100,
|
||||||
|
height: sourceNode.height ?? 100,
|
||||||
|
},
|
||||||
|
targetCenter,
|
||||||
|
sourceCenter
|
||||||
|
)
|
||||||
|
: intersection(sourceNode, sourceCenter, targetCenter);
|
||||||
|
|
||||||
|
let endPos = isTargetRound
|
||||||
|
? computeCircleEdgeIntersection(
|
||||||
|
{
|
||||||
|
x: targetNode.x,
|
||||||
|
y: targetNode.y,
|
||||||
|
width: targetNode.width ?? 100,
|
||||||
|
height: targetNode.height ?? 100,
|
||||||
|
},
|
||||||
|
sourceCenter,
|
||||||
|
targetCenter
|
||||||
|
)
|
||||||
|
: intersection(targetNode, targetCenter, sourceCenter);
|
||||||
|
|
||||||
|
const midX = (startPos.x + endPos.x) / 2;
|
||||||
|
const midY = (startPos.y + endPos.y) / 2;
|
||||||
|
|
||||||
|
const points = [startPos];
|
||||||
|
if (sourceNode.section === 'left') {
|
||||||
|
points.push({
|
||||||
|
x: sourceNode.x - (sourceNode.width ?? 0) / 2 - intersectionShift,
|
||||||
|
y: sourceNode.y,
|
||||||
|
});
|
||||||
|
} else if (sourceNode.section === 'right') {
|
||||||
|
points.push({
|
||||||
|
x: sourceNode.x + (sourceNode.width ?? 0) / 2 + intersectionShift,
|
||||||
|
y: sourceNode.y,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (targetNode.section === 'left') {
|
||||||
|
points.push({
|
||||||
|
x: targetNode.x + (targetNode.width ?? 0) / 2 + intersectionShift,
|
||||||
|
y: targetNode.y,
|
||||||
|
});
|
||||||
|
} else if (targetNode.section === 'right') {
|
||||||
|
points.push({
|
||||||
|
x: targetNode.x - (targetNode.width ?? 0) / 2 - intersectionShift,
|
||||||
|
y: targetNode.y,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
points.push(endPos);
|
||||||
|
|
||||||
|
const secondPoint = points.length > 1 ? points[1] : targetCenter;
|
||||||
|
startPos = isSourceRound
|
||||||
|
? computeCircleEdgeIntersection(
|
||||||
|
{
|
||||||
|
x: sourceNode.x,
|
||||||
|
y: sourceNode.y,
|
||||||
|
width: sourceNode.width ?? 100,
|
||||||
|
height: sourceNode.height ?? 100,
|
||||||
|
},
|
||||||
|
secondPoint,
|
||||||
|
sourceCenter
|
||||||
|
)
|
||||||
|
: intersection(sourceNode, secondPoint, sourceCenter);
|
||||||
|
points[0] = startPos;
|
||||||
|
|
||||||
|
const secondLastPoint = points.length > 1 ? points[points.length - 2] : sourceCenter;
|
||||||
|
endPos = isTargetRound
|
||||||
|
? computeCircleEdgeIntersection(
|
||||||
|
{
|
||||||
|
x: targetNode.x,
|
||||||
|
y: targetNode.y,
|
||||||
|
width: targetNode.width ?? 100,
|
||||||
|
height: targetNode.height ?? 100,
|
||||||
|
},
|
||||||
|
secondLastPoint,
|
||||||
|
targetCenter
|
||||||
|
)
|
||||||
|
: intersection(targetNode, secondLastPoint, targetCenter);
|
||||||
|
points[points.length - 1] = endPos;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: edge.id,
|
||||||
|
source: edge.start ?? '',
|
||||||
|
target: edge.end ?? '',
|
||||||
|
startX: startPos.x,
|
||||||
|
startY: startPos.y,
|
||||||
|
midX,
|
||||||
|
midY,
|
||||||
|
endX: endPos.x,
|
||||||
|
endY: endPos.y,
|
||||||
|
points,
|
||||||
|
sourceSection: sourceNode?.section,
|
||||||
|
targetSection: targetNode?.section,
|
||||||
|
sourceWidth: sourceNode?.width,
|
||||||
|
sourceHeight: sourceNode?.height,
|
||||||
|
targetWidth: targetNode?.width,
|
||||||
|
targetHeight: targetNode?.height,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate layout data structure
|
||||||
|
* @param data - The data to validate
|
||||||
|
* @returns True if data is valid, throws error otherwise
|
||||||
|
*/
|
||||||
|
export function validateLayoutData(data: LayoutData): boolean {
|
||||||
|
if (!data) {
|
||||||
|
throw new Error('Layout data is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.config) {
|
||||||
|
throw new Error('Configuration is required in layout data');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(data.nodes)) {
|
||||||
|
throw new Error('Nodes array is required in layout data');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(data.edges)) {
|
||||||
|
throw new Error('Edges array is required in layout data');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
13
packages/mermaid-layout-tidy-tree/src/layouts.ts
Normal file
13
packages/mermaid-layout-tidy-tree/src/layouts.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import type { LayoutLoaderDefinition } from 'mermaid';
|
||||||
|
|
||||||
|
const loader = async () => await import(`./render.js`);
|
||||||
|
|
||||||
|
const tidyTreeLayout: LayoutLoaderDefinition[] = [
|
||||||
|
{
|
||||||
|
name: 'tidy-tree',
|
||||||
|
loader,
|
||||||
|
algorithm: 'tidy-tree',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default tidyTreeLayout;
|
18
packages/mermaid-layout-tidy-tree/src/non-layered-tidy-tree-layout.d.ts
vendored
Normal file
18
packages/mermaid-layout-tidy-tree/src/non-layered-tidy-tree-layout.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
declare module 'non-layered-tidy-tree-layout' {
|
||||||
|
export class BoundingBox {
|
||||||
|
constructor(gap: number, bottomPadding: number);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Layout {
|
||||||
|
constructor(boundingBox: BoundingBox);
|
||||||
|
layout(data: any): {
|
||||||
|
result: any;
|
||||||
|
boundingBox: {
|
||||||
|
left: number;
|
||||||
|
right: number;
|
||||||
|
top: number;
|
||||||
|
bottom: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
180
packages/mermaid-layout-tidy-tree/src/render.ts
Normal file
180
packages/mermaid-layout-tidy-tree/src/render.ts
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
import type { InternalHelpers, LayoutData, RenderOptions, SVG } from 'mermaid';
|
||||||
|
import { executeTidyTreeLayout } from './layout.js';
|
||||||
|
|
||||||
|
interface NodeWithPosition {
|
||||||
|
id: string;
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
domId?: any;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render function for bidirectional tidy-tree layout algorithm
|
||||||
|
*
|
||||||
|
* This follows the same pattern as ELK and dagre renderers:
|
||||||
|
* 1. Insert nodes into DOM to get their actual dimensions
|
||||||
|
* 2. Run the bidirectional tidy-tree layout algorithm to calculate positions
|
||||||
|
* 3. Position the nodes and edges based on layout results
|
||||||
|
*
|
||||||
|
* The bidirectional layout creates two trees that grow horizontally in opposite
|
||||||
|
* directions from a central root node:
|
||||||
|
* - Left tree: grows horizontally to the left (children: 1st, 3rd, 5th...)
|
||||||
|
* - Right tree: grows horizontally to the right (children: 2nd, 4th, 6th...)
|
||||||
|
*/
|
||||||
|
export const render = async (
|
||||||
|
data4Layout: LayoutData,
|
||||||
|
svg: SVG,
|
||||||
|
{
|
||||||
|
insertCluster,
|
||||||
|
insertEdge,
|
||||||
|
insertEdgeLabel,
|
||||||
|
insertMarkers,
|
||||||
|
insertNode,
|
||||||
|
log,
|
||||||
|
positionEdgeLabel,
|
||||||
|
}: InternalHelpers,
|
||||||
|
{ algorithm: _algorithm }: RenderOptions
|
||||||
|
) => {
|
||||||
|
const nodeDb: Record<string, NodeWithPosition> = {};
|
||||||
|
const clusterDb: Record<string, any> = {};
|
||||||
|
|
||||||
|
const element = svg.select('g');
|
||||||
|
insertMarkers(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
|
||||||
|
|
||||||
|
const subGraphsEl = element.insert('g').attr('class', 'subgraphs');
|
||||||
|
const edgePaths = element.insert('g').attr('class', 'edgePaths');
|
||||||
|
const edgeLabels = element.insert('g').attr('class', 'edgeLabels');
|
||||||
|
const nodes = element.insert('g').attr('class', 'nodes');
|
||||||
|
// Step 1: Insert nodes into DOM to get their actual dimensions
|
||||||
|
log.debug('Inserting nodes into DOM for dimension calculation');
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
data4Layout.nodes.map(async (node) => {
|
||||||
|
if (node.isGroup) {
|
||||||
|
const clusterNode: NodeWithPosition = {
|
||||||
|
...node,
|
||||||
|
id: node.id,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
};
|
||||||
|
clusterDb[node.id] = clusterNode;
|
||||||
|
nodeDb[node.id] = clusterNode;
|
||||||
|
|
||||||
|
await insertCluster(subGraphsEl, node);
|
||||||
|
} else {
|
||||||
|
const nodeWithPosition: NodeWithPosition = {
|
||||||
|
...node,
|
||||||
|
id: node.id,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
};
|
||||||
|
nodeDb[node.id] = nodeWithPosition;
|
||||||
|
|
||||||
|
const nodeEl = await insertNode(nodes, node, {
|
||||||
|
config: data4Layout.config,
|
||||||
|
dir: data4Layout.direction || 'TB',
|
||||||
|
});
|
||||||
|
|
||||||
|
const boundingBox = nodeEl.node()!.getBBox();
|
||||||
|
nodeWithPosition.width = boundingBox.width;
|
||||||
|
nodeWithPosition.height = boundingBox.height;
|
||||||
|
nodeWithPosition.domId = nodeEl;
|
||||||
|
|
||||||
|
log.debug(`Node ${node.id} dimensions: ${boundingBox.width}x${boundingBox.height}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// Step 2: Run the bidirectional tidy-tree layout algorithm
|
||||||
|
log.debug('Running bidirectional tidy-tree layout algorithm');
|
||||||
|
|
||||||
|
const updatedLayoutData = {
|
||||||
|
...data4Layout,
|
||||||
|
nodes: data4Layout.nodes.map((node) => {
|
||||||
|
const nodeWithDimensions = nodeDb[node.id];
|
||||||
|
return {
|
||||||
|
...node,
|
||||||
|
width: nodeWithDimensions.width ?? node.width ?? 100,
|
||||||
|
height: nodeWithDimensions.height ?? node.height ?? 50,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
const layoutResult = await executeTidyTreeLayout(updatedLayoutData, data4Layout.config);
|
||||||
|
// Step 3: Position the nodes based on bidirectional layout results
|
||||||
|
log.debug('Positioning nodes based on bidirectional layout results');
|
||||||
|
|
||||||
|
layoutResult.nodes.forEach((positionedNode) => {
|
||||||
|
const node = nodeDb[positionedNode.id];
|
||||||
|
if (node?.domId) {
|
||||||
|
// Position the node at the calculated coordinates from bidirectional layout
|
||||||
|
// The layout algorithm has already calculated positions for:
|
||||||
|
// - Root node at center (0, 0)
|
||||||
|
// - Left tree nodes with negative x coordinates (growing left)
|
||||||
|
// - Right tree nodes with positive x coordinates (growing right)
|
||||||
|
node.domId.attr('transform', `translate(${positionedNode.x}, ${positionedNode.y})`);
|
||||||
|
// Store the final position
|
||||||
|
node.x = positionedNode.x;
|
||||||
|
node.y = positionedNode.y;
|
||||||
|
// Step 3: Position the nodes based on bidirectional layout results
|
||||||
|
log.debug(`Positioned node ${node.id} at (${positionedNode.x}, ${positionedNode.y})`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
log.debug('Inserting and positioning edges');
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
data4Layout.edges.map(async (edge) => {
|
||||||
|
await insertEdgeLabel(edgeLabels, edge);
|
||||||
|
|
||||||
|
const startNode = nodeDb[edge.start ?? ''];
|
||||||
|
const endNode = nodeDb[edge.end ?? ''];
|
||||||
|
|
||||||
|
if (startNode && endNode) {
|
||||||
|
const positionedEdge = layoutResult.edges.find((e) => e.id === edge.id);
|
||||||
|
|
||||||
|
if (positionedEdge) {
|
||||||
|
log.debug('APA01 positionedEdge', positionedEdge);
|
||||||
|
const edgeWithPath = {
|
||||||
|
...edge,
|
||||||
|
points: positionedEdge.points,
|
||||||
|
};
|
||||||
|
const paths = insertEdge(
|
||||||
|
edgePaths,
|
||||||
|
edgeWithPath,
|
||||||
|
clusterDb,
|
||||||
|
data4Layout.type,
|
||||||
|
startNode,
|
||||||
|
endNode,
|
||||||
|
data4Layout.diagramId
|
||||||
|
);
|
||||||
|
|
||||||
|
positionEdgeLabel(edgeWithPath, paths);
|
||||||
|
} else {
|
||||||
|
const edgeWithPath = {
|
||||||
|
...edge,
|
||||||
|
points: [
|
||||||
|
{ x: startNode.x ?? 0, y: startNode.y ?? 0 },
|
||||||
|
{ x: endNode.x ?? 0, y: endNode.y ?? 0 },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const paths = insertEdge(
|
||||||
|
edgePaths,
|
||||||
|
edgeWithPath,
|
||||||
|
clusterDb,
|
||||||
|
data4Layout.type,
|
||||||
|
startNode,
|
||||||
|
endNode,
|
||||||
|
data4Layout.diagramId
|
||||||
|
);
|
||||||
|
positionEdgeLabel(edgeWithPath, paths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
log.debug('Bidirectional tidy-tree rendering completed');
|
||||||
|
};
|
69
packages/mermaid-layout-tidy-tree/src/types.ts
Normal file
69
packages/mermaid-layout-tidy-tree/src/types.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import type { LayoutData } from 'mermaid';
|
||||||
|
|
||||||
|
export type Node = LayoutData['nodes'][number];
|
||||||
|
export type Edge = LayoutData['edges'][number];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Positioned node after layout calculation
|
||||||
|
*/
|
||||||
|
export interface PositionedNode {
|
||||||
|
id: string;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
section?: 'root' | 'left' | 'right';
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
originalNode?: Node;
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Positioned edge after layout calculation
|
||||||
|
*/
|
||||||
|
export interface PositionedEdge {
|
||||||
|
id: string;
|
||||||
|
source: string;
|
||||||
|
target: string;
|
||||||
|
startX: number;
|
||||||
|
startY: number;
|
||||||
|
midX: number;
|
||||||
|
midY: number;
|
||||||
|
endX: number;
|
||||||
|
endY: number;
|
||||||
|
sourceSection?: 'root' | 'left' | 'right';
|
||||||
|
targetSection?: 'root' | 'left' | 'right';
|
||||||
|
sourceWidth?: number;
|
||||||
|
sourceHeight?: number;
|
||||||
|
targetWidth?: number;
|
||||||
|
targetHeight?: number;
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result of layout algorithm execution
|
||||||
|
*/
|
||||||
|
export interface LayoutResult {
|
||||||
|
nodes: PositionedNode[];
|
||||||
|
edges: PositionedEdge[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tidy-tree node structure compatible with non-layered-tidy-tree-layout
|
||||||
|
*/
|
||||||
|
export interface TidyTreeNode {
|
||||||
|
id: string | number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
|
children?: TidyTreeNode[];
|
||||||
|
_originalNode?: Node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tidy-tree layout configuration
|
||||||
|
*/
|
||||||
|
export interface TidyTreeLayoutConfig {
|
||||||
|
gap: number;
|
||||||
|
bottomPadding: number;
|
||||||
|
}
|
10
packages/mermaid-layout-tidy-tree/tsconfig.json
Normal file
10
packages/mermaid-layout-tidy-tree/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"types": ["vitest/importMeta", "vitest/globals"]
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*.ts", "./src/**/*.d.ts"],
|
||||||
|
"typeRoots": ["./src/types"]
|
||||||
|
}
|
@@ -87,7 +87,6 @@
|
|||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- [#6408](https://github.com/mermaid-js/mermaid/pull/6408) [`ad65313`](https://github.com/mermaid-js/mermaid/commit/ad653138e16765d095613a6e5de86dc5e52ac8f0) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - fix: restore curve type configuration functionality for flowcharts. This fixes the issue where curve type settings were not being applied when configured through any of the following methods:
|
- [#6408](https://github.com/mermaid-js/mermaid/pull/6408) [`ad65313`](https://github.com/mermaid-js/mermaid/commit/ad653138e16765d095613a6e5de86dc5e52ac8f0) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - fix: restore curve type configuration functionality for flowcharts. This fixes the issue where curve type settings were not being applied when configured through any of the following methods:
|
||||||
|
|
||||||
- Config
|
- Config
|
||||||
- Init directive (%%{ init: { 'flowchart': { 'curve': '...' } } }%%)
|
- Init directive (%%{ init: { 'flowchart': { 'curve': '...' } } }%%)
|
||||||
- LinkStyle command (linkStyle default interpolate ...)
|
- LinkStyle command (linkStyle default interpolate ...)
|
||||||
@@ -106,14 +105,12 @@
|
|||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- [#6187](https://github.com/mermaid-js/mermaid/pull/6187) [`7809b5a`](https://github.com/mermaid-js/mermaid/commit/7809b5a93fae127f45727071f5ff14325222c518) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - Flowchart new syntax for node metadata bugs
|
- [#6187](https://github.com/mermaid-js/mermaid/pull/6187) [`7809b5a`](https://github.com/mermaid-js/mermaid/commit/7809b5a93fae127f45727071f5ff14325222c518) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - Flowchart new syntax for node metadata bugs
|
||||||
|
|
||||||
- Incorrect label mapping for nodes when using `&`
|
- Incorrect label mapping for nodes when using `&`
|
||||||
- Syntax error when `}` with trailing spaces before new line
|
- Syntax error when `}` with trailing spaces before new line
|
||||||
|
|
||||||
- [#6136](https://github.com/mermaid-js/mermaid/pull/6136) [`ec0d9c3`](https://github.com/mermaid-js/mermaid/commit/ec0d9c389aa6018043187654044c1e0b5aa4f600) Thanks [@knsv](https://github.com/knsv)! - Adding support for animation of flowchart edges
|
- [#6136](https://github.com/mermaid-js/mermaid/pull/6136) [`ec0d9c3`](https://github.com/mermaid-js/mermaid/commit/ec0d9c389aa6018043187654044c1e0b5aa4f600) Thanks [@knsv](https://github.com/knsv)! - Adding support for animation of flowchart edges
|
||||||
|
|
||||||
- [#6373](https://github.com/mermaid-js/mermaid/pull/6373) [`05bdf0e`](https://github.com/mermaid-js/mermaid/commit/05bdf0e20e2629fe77513218fbd4e28e65f75882) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - Upgrade Requirement and ER diagram to use the common renderer flow
|
- [#6373](https://github.com/mermaid-js/mermaid/pull/6373) [`05bdf0e`](https://github.com/mermaid-js/mermaid/commit/05bdf0e20e2629fe77513218fbd4e28e65f75882) Thanks [@ashishjain0512](https://github.com/ashishjain0512)! - Upgrade Requirement and ER diagram to use the common renderer flow
|
||||||
|
|
||||||
- Added support for directions
|
- Added support for directions
|
||||||
- Added support for hand drawn look
|
- Added support for hand drawn look
|
||||||
|
|
||||||
@@ -162,7 +159,6 @@
|
|||||||
- [#5999](https://github.com/mermaid-js/mermaid/pull/5999) [`742ad7c`](https://github.com/mermaid-js/mermaid/commit/742ad7c130964df1fb5544e909d9556081285f68) Thanks [@knsv](https://github.com/knsv)! - Adding Kanban board, a new diagram type
|
- [#5999](https://github.com/mermaid-js/mermaid/pull/5999) [`742ad7c`](https://github.com/mermaid-js/mermaid/commit/742ad7c130964df1fb5544e909d9556081285f68) Thanks [@knsv](https://github.com/knsv)! - Adding Kanban board, a new diagram type
|
||||||
|
|
||||||
- [#5880](https://github.com/mermaid-js/mermaid/pull/5880) [`bdf145f`](https://github.com/mermaid-js/mermaid/commit/bdf145ffe362462176d9c1e68d5f3ff5c9d962b0) Thanks [@yari-dewalt](https://github.com/yari-dewalt)! - Class diagram changes:
|
- [#5880](https://github.com/mermaid-js/mermaid/pull/5880) [`bdf145f`](https://github.com/mermaid-js/mermaid/commit/bdf145ffe362462176d9c1e68d5f3ff5c9d962b0) Thanks [@yari-dewalt](https://github.com/yari-dewalt)! - Class diagram changes:
|
||||||
|
|
||||||
- Updates the class diagram to the new unified way of rendering.
|
- Updates the class diagram to the new unified way of rendering.
|
||||||
- Includes a new "classBox" shape to be used in diagrams
|
- Includes a new "classBox" shape to be used in diagrams
|
||||||
- Other updates such as:
|
- Other updates such as:
|
||||||
|
@@ -82,7 +82,7 @@
|
|||||||
"katex": "^0.16.22",
|
"katex": "^0.16.22",
|
||||||
"khroma": "^2.1.0",
|
"khroma": "^2.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"marked": "^16.0.0",
|
"marked": "^15.0.7",
|
||||||
"roughjs": "^4.6.6",
|
"roughjs": "^4.6.6",
|
||||||
"stylis": "^4.3.6",
|
"stylis": "^4.3.6",
|
||||||
"ts-dedent": "^2.2.0",
|
"ts-dedent": "^2.2.0",
|
||||||
@@ -123,8 +123,8 @@
|
|||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"start-server-and-test": "^2.0.10",
|
"start-server-and-test": "^2.0.10",
|
||||||
"type-fest": "^4.35.0",
|
"type-fest": "^4.35.0",
|
||||||
"typedoc": "^0.27.8",
|
"typedoc": "^0.28.9",
|
||||||
"typedoc-plugin-markdown": "^4.4.2",
|
"typedoc-plugin-markdown": "^4.8.0",
|
||||||
"typescript": "~5.7.3",
|
"typescript": "~5.7.3",
|
||||||
"unist-util-flatmap": "^1.0.0",
|
"unist-util-flatmap": "^1.0.0",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
|
@@ -171,7 +171,9 @@ This Markdown should be kept.
|
|||||||
expect(buildShapeDoc()).toMatchInlineSnapshot(`
|
expect(buildShapeDoc()).toMatchInlineSnapshot(`
|
||||||
"| **Semantic Name** | **Shape Name** | **Short Name** | **Description** | **Alias Supported** |
|
"| **Semantic Name** | **Shape Name** | **Short Name** | **Description** | **Alias Supported** |
|
||||||
| --------------------------------- | ---------------------- | -------------- | ------------------------------ | ---------------------------------------------------------------- |
|
| --------------------------------- | ---------------------- | -------------- | ------------------------------ | ---------------------------------------------------------------- |
|
||||||
|
| Bang | Bang | \`bang\` | Bang | \`bang\` |
|
||||||
| Card | Notched Rectangle | \`notch-rect\` | Represents a card | \`card\`, \`notched-rectangle\` |
|
| Card | Notched Rectangle | \`notch-rect\` | Represents a card | \`card\`, \`notched-rectangle\` |
|
||||||
|
| Cloud | Cloud | \`cloud\` | cloud | \`cloud\` |
|
||||||
| Collate | Hourglass | \`hourglass\` | Represents a collate operation | \`collate\`, \`hourglass\` |
|
| Collate | Hourglass | \`hourglass\` | Represents a collate operation | \`collate\`, \`hourglass\` |
|
||||||
| Com Link | Lightning Bolt | \`bolt\` | Communication link | \`com-link\`, \`lightning-bolt\` |
|
| Com Link | Lightning Bolt | \`bolt\` | Communication link | \`com-link\`, \`lightning-bolt\` |
|
||||||
| Comment | Curly Brace | \`brace\` | Adds a comment | \`brace-l\`, \`comment\` |
|
| Comment | Curly Brace | \`brace\` | Adds a comment | \`brace-l\`, \`comment\` |
|
||||||
|
@@ -1065,6 +1065,10 @@ export interface ArchitectureDiagramConfig extends BaseDiagramConfig {
|
|||||||
export interface MindmapDiagramConfig extends BaseDiagramConfig {
|
export interface MindmapDiagramConfig extends BaseDiagramConfig {
|
||||||
padding?: number;
|
padding?: number;
|
||||||
maxNodeWidth?: number;
|
maxNodeWidth?: number;
|
||||||
|
/**
|
||||||
|
* Layout algorithm to use for positioning mindmap nodes
|
||||||
|
*/
|
||||||
|
layoutAlgorithm?: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The object containing configurations specific for kanban diagrams
|
* The object containing configurations specific for kanban diagrams
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
// tests to check that comments are removed
|
|
||||||
|
|
||||||
import { cleanupComments } from './comments.js';
|
import { cleanupComments } from './comments.js';
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
|
|
||||||
|
@@ -4,5 +4,6 @@
|
|||||||
* @returns cleaned text
|
* @returns cleaned text
|
||||||
*/
|
*/
|
||||||
export const cleanupComments = (text: string): string => {
|
export const cleanupComments = (text: string): string => {
|
||||||
return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, '').trimStart();
|
const cleaned = text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, '');
|
||||||
|
return cleaned.trimStart();
|
||||||
};
|
};
|
||||||
|
@@ -28,7 +28,6 @@ import architecture from '../diagrams/architecture/architectureDetector.js';
|
|||||||
import { registerLazyLoadedDiagrams } from './detectType.js';
|
import { registerLazyLoadedDiagrams } from './detectType.js';
|
||||||
import { registerDiagram } from './diagramAPI.js';
|
import { registerDiagram } from './diagramAPI.js';
|
||||||
import { treemap } from '../diagrams/treemap/detector.js';
|
import { treemap } from '../diagrams/treemap/detector.js';
|
||||||
import { usecase } from '../diagrams/usecase/detector.js';
|
|
||||||
import '../type.d.ts';
|
import '../type.d.ts';
|
||||||
|
|
||||||
let hasLoadedDiagrams = false;
|
let hasLoadedDiagrams = false;
|
||||||
@@ -102,7 +101,6 @@ export const addDiagrams = () => {
|
|||||||
xychart,
|
xychart,
|
||||||
block,
|
block,
|
||||||
radar,
|
radar,
|
||||||
treemap,
|
treemap
|
||||||
usecase
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import type { Position } from 'cytoscape';
|
import type { LayoutOptions, Position } from 'cytoscape';
|
||||||
import cytoscape from 'cytoscape';
|
import cytoscape from 'cytoscape';
|
||||||
import type { FcoseLayoutOptions } from 'cytoscape-fcose';
|
|
||||||
import fcose from 'cytoscape-fcose';
|
import fcose from 'cytoscape-fcose';
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import type { DrawDefinition, SVG } from '../../diagram-api/types.js';
|
import type { DrawDefinition, SVG } from '../../diagram-api/types.js';
|
||||||
@@ -41,7 +40,7 @@ registerIconPacks([
|
|||||||
icons: architectureIcons,
|
icons: architectureIcons,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
cytoscape.use(fcose);
|
cytoscape.use(fcose as any);
|
||||||
|
|
||||||
function addServices(services: ArchitectureService[], cy: cytoscape.Core, db: ArchitectureDB) {
|
function addServices(services: ArchitectureService[], cy: cytoscape.Core, db: ArchitectureDB) {
|
||||||
services.forEach((service) => {
|
services.forEach((service) => {
|
||||||
@@ -429,7 +428,7 @@ function layoutArchitecture(
|
|||||||
},
|
},
|
||||||
alignmentConstraint,
|
alignmentConstraint,
|
||||||
relativePlacementConstraint,
|
relativePlacementConstraint,
|
||||||
} as FcoseLayoutOptions);
|
} as LayoutOptions);
|
||||||
|
|
||||||
// Once the diagram has been generated and the service's position cords are set, adjust the XY edges to have a 90deg bend
|
// Once the diagram has been generated and the service's position cords are set, adjust the XY edges to have a 90deg bend
|
||||||
layout.one('layoutstop', () => {
|
layout.one('layoutstop', () => {
|
||||||
|
@@ -238,13 +238,15 @@ export function edgeTypeStr2Type(typeStr: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function edgeStrToEdgeData(typeStr: string): string {
|
export function edgeStrToEdgeData(typeStr: string): string {
|
||||||
switch (typeStr.trim()) {
|
switch (typeStr.replace(/^[\s-]+|[\s-]+$/g, '')) {
|
||||||
case '--x':
|
case 'x':
|
||||||
return 'arrow_cross';
|
return 'arrow_cross';
|
||||||
case '--o':
|
case 'o':
|
||||||
return 'arrow_circle';
|
return 'arrow_circle';
|
||||||
default:
|
case '>':
|
||||||
return 'arrow_point';
|
return 'arrow_point';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-a
|
|||||||
const id = 'block';
|
const id = 'block';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
return /^\s*block-beta/.test(txt);
|
return /^\s*block(-beta)?/.test(txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
|
@@ -36,10 +36,10 @@ CRLF \u000D\u000A
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
"block-beta" { return 'BLOCK_DIAGRAM_KEY'; }
|
"block-beta" { yy.getLogger().debug('Found block-beta'); return 'BLOCK_DIAGRAM_KEY'; }
|
||||||
"block"\s+ { yy.getLogger().debug('Found space-block'); return 'block';}
|
"block:" { yy.getLogger().debug('Found id-block'); return 'id-block'; }
|
||||||
"block"\n+ { yy.getLogger().debug('Found nl-block'); return 'block';}
|
"block" { yy.getLogger().debug('Found block'); return 'BLOCK_DIAGRAM_KEY'; }
|
||||||
"block:" { yy.getLogger().debug('Found space-block'); return 'id-block';}
|
|
||||||
// \s*\%\%.* { yy.getLogger().debug('Found comment',yytext); }
|
// \s*\%\%.* { yy.getLogger().debug('Found comment',yytext); }
|
||||||
[\s]+ { yy.getLogger().debug('.', yytext); /* skip all whitespace */ }
|
[\s]+ { yy.getLogger().debug('.', yytext); /* skip all whitespace */ }
|
||||||
[\n]+ {yy.getLogger().debug('_', yytext); /* skip all whitespace */ }
|
[\n]+ {yy.getLogger().debug('_', yytext); /* skip all whitespace */ }
|
||||||
@@ -240,7 +240,7 @@ columnsStatement
|
|||||||
|
|
||||||
blockStatement
|
blockStatement
|
||||||
: id-block nodeStatement document end { yy.getLogger().debug('Rule: id-block statement : ', $2, $3); const id2 = yy.generateId(); $$ = { ...$2, type:'composite', children: $3 }; }
|
: id-block nodeStatement document end { yy.getLogger().debug('Rule: id-block statement : ', $2, $3); const id2 = yy.generateId(); $$ = { ...$2, type:'composite', children: $3 }; }
|
||||||
| block document end { yy.getLogger().debug('Rule: blockStatement : ', $1, $2, $3); const id = yy.generateId(); $$ = { id, type:'composite', label:'', children: $2 }; }
|
| BLOCK_DIAGRAM_KEY document end { yy.getLogger().debug('Rule: blockStatement : ', $1, $2, $3); const id = yy.generateId(); $$ = { id, type:'composite', label:'', children: $2 }; }
|
||||||
;
|
;
|
||||||
|
|
||||||
node
|
node
|
||||||
|
@@ -23,7 +23,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks[0].label).toBe('id');
|
expect(blocks[0].label).toBe('id');
|
||||||
});
|
});
|
||||||
it('a node with a square shape and a label', () => {
|
it('a node with a square shape and a label', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id["A label"]
|
id["A label"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks[0].type).toBe('square');
|
expect(blocks[0].type).toBe('square');
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes', () => {
|
it('a diagram with multiple nodes', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id1
|
id1
|
||||||
id2
|
id2
|
||||||
`;
|
`;
|
||||||
@@ -51,7 +51,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks[1].type).toBe('na');
|
expect(blocks[1].type).toBe('na');
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes', () => {
|
it('a diagram with multiple nodes', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id1
|
id1
|
||||||
id2
|
id2
|
||||||
id3
|
id3
|
||||||
@@ -72,7 +72,7 @@ describe('Block diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('a node with a square shape and a label', () => {
|
it('a node with a square shape and a label', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id["A label"]
|
id["A label"]
|
||||||
id2`;
|
id2`;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks[1].type).toBe('na');
|
expect(blocks[1].type).toBe('na');
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes with edges abc123', () => {
|
it('a diagram with multiple nodes with edges abc123', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id1["first"] --> id2["second"]
|
id1["first"] --> id2["second"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ describe('Block diagram', function () {
|
|||||||
expect(edges[0].arrowTypeEnd).toBe('arrow_point');
|
expect(edges[0].arrowTypeEnd).toBe('arrow_point');
|
||||||
});
|
});
|
||||||
it('a diagram with multiple nodes with edges abc123', () => {
|
it('a diagram with multiple nodes with edges abc123', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
id1["first"] -- "a label" --> id2["second"]
|
id1["first"] -- "a label" --> id2["second"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ describe('Block diagram', function () {
|
|||||||
expect(edges[0].label).toBe('a label');
|
expect(edges[0].label).toBe('a label');
|
||||||
});
|
});
|
||||||
it('a diagram with column statements', () => {
|
it('a diagram with column statements', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 2
|
columns 2
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
`;
|
`;
|
||||||
@@ -127,7 +127,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks.length).toBe(1);
|
expect(blocks.length).toBe(1);
|
||||||
});
|
});
|
||||||
it('a diagram without column statements', () => {
|
it('a diagram without column statements', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blocks.length).toBe(1);
|
expect(blocks.length).toBe(1);
|
||||||
});
|
});
|
||||||
it('a diagram with auto column statements', () => {
|
it('a diagram with auto column statements', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns auto
|
columns auto
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
`;
|
`;
|
||||||
@@ -149,7 +149,7 @@ describe('Block diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('blocks next to each other', () => {
|
it('blocks next to each other', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 2
|
columns 2
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
block2["Block 2"]
|
block2["Block 2"]
|
||||||
@@ -163,7 +163,7 @@ describe('Block diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('blocks on top of each other', () => {
|
it('blocks on top of each other', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 1
|
columns 1
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
block2["Block 2"]
|
block2["Block 2"]
|
||||||
@@ -177,7 +177,7 @@ describe('Block diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('compound blocks 2', () => {
|
it('compound blocks 2', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
block
|
block
|
||||||
aBlock["ABlock"]
|
aBlock["ABlock"]
|
||||||
bBlock["BBlock"]
|
bBlock["BBlock"]
|
||||||
@@ -205,7 +205,7 @@ describe('Block diagram', function () {
|
|||||||
expect(bBlock.type).toBe('square');
|
expect(bBlock.type).toBe('square');
|
||||||
});
|
});
|
||||||
it('compound blocks of compound blocks', () => {
|
it('compound blocks of compound blocks', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
block
|
block
|
||||||
aBlock["ABlock"]
|
aBlock["ABlock"]
|
||||||
block
|
block
|
||||||
@@ -240,7 +240,7 @@ describe('Block diagram', function () {
|
|||||||
expect(bBlock.type).toBe('square');
|
expect(bBlock.type).toBe('square');
|
||||||
});
|
});
|
||||||
it('compound blocks with title', () => {
|
it('compound blocks with title', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
block:compoundBlock["Compound block"]
|
block:compoundBlock["Compound block"]
|
||||||
columns 1
|
columns 1
|
||||||
block2["Block 2"]
|
block2["Block 2"]
|
||||||
@@ -265,7 +265,7 @@ describe('Block diagram', function () {
|
|||||||
expect(block2.type).toBe('square');
|
expect(block2.type).toBe('square');
|
||||||
});
|
});
|
||||||
it('blocks mixed with compound blocks', () => {
|
it('blocks mixed with compound blocks', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 1
|
columns 1
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ describe('Block diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Arrow blocks', () => {
|
it('Arrow blocks', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 3
|
columns 3
|
||||||
block1["Block 1"]
|
block1["Block 1"]
|
||||||
blockArrow<[" "]>(right)
|
blockArrow<[" "]>(right)
|
||||||
@@ -316,7 +316,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blockArrow.directions).toContain('right');
|
expect(blockArrow.directions).toContain('right');
|
||||||
});
|
});
|
||||||
it('Arrow blocks with multiple points', () => {
|
it('Arrow blocks with multiple points', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 1
|
columns 1
|
||||||
A
|
A
|
||||||
blockArrow<[" "]>(up, down)
|
blockArrow<[" "]>(up, down)
|
||||||
@@ -339,7 +339,7 @@ describe('Block diagram', function () {
|
|||||||
expect(blockArrow.directions).not.toContain('right');
|
expect(blockArrow.directions).not.toContain('right');
|
||||||
});
|
});
|
||||||
it('blocks with different widths', () => {
|
it('blocks with different widths', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 3
|
columns 3
|
||||||
one["One Slot"]
|
one["One Slot"]
|
||||||
two["Two slots"]:2
|
two["Two slots"]:2
|
||||||
@@ -354,7 +354,7 @@ describe('Block diagram', function () {
|
|||||||
expect(two.widthInColumns).toBe(2);
|
expect(two.widthInColumns).toBe(2);
|
||||||
});
|
});
|
||||||
it('empty blocks', () => {
|
it('empty blocks', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 3
|
columns 3
|
||||||
space
|
space
|
||||||
middle["In the middle"]
|
middle["In the middle"]
|
||||||
@@ -373,7 +373,7 @@ describe('Block diagram', function () {
|
|||||||
expect(middle.label).toBe('In the middle');
|
expect(middle.label).toBe('In the middle');
|
||||||
});
|
});
|
||||||
it('classDef statements applied to a block', () => {
|
it('classDef statements applied to a block', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
classDef black color:#ffffff, fill:#000000;
|
classDef black color:#ffffff, fill:#000000;
|
||||||
|
|
||||||
mc["Memcache"]
|
mc["Memcache"]
|
||||||
@@ -391,7 +391,7 @@ describe('Block diagram', function () {
|
|||||||
expect(black.styles[0]).toEqual('color:#ffffff');
|
expect(black.styles[0]).toEqual('color:#ffffff');
|
||||||
});
|
});
|
||||||
it('style statements applied to a block', () => {
|
it('style statements applied to a block', () => {
|
||||||
const str = `block-beta
|
const str = `block
|
||||||
columns 1
|
columns 1
|
||||||
B["A wide one in the middle"]
|
B["A wide one in the middle"]
|
||||||
style B fill:#f9F,stroke:#333,stroke-width:4px
|
style B fill:#f9F,stroke:#333,stroke-width:4px
|
||||||
@@ -426,9 +426,9 @@ columns 1
|
|||||||
|
|
||||||
describe('prototype properties', function () {
|
describe('prototype properties', function () {
|
||||||
function validateProperty(prop: string) {
|
function validateProperty(prop: string) {
|
||||||
expect(() => block.parse(`block-beta\n${prop}`)).not.toThrow();
|
expect(() => block.parse(`block\n${prop}`)).not.toThrow();
|
||||||
expect(() =>
|
expect(() =>
|
||||||
block.parse(`block-beta\nA; classDef ${prop} color:#ffffff,fill:#000000; class A ${prop}`)
|
block.parse(`block\nA; classDef ${prop} color:#ffffff,fill:#000000; class A ${prop}`)
|
||||||
).not.toThrow();
|
).not.toThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,13 +33,13 @@ function setupDompurifyHooks() {
|
|||||||
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
||||||
|
|
||||||
DOMPurify.addHook('beforeSanitizeAttributes', (node) => {
|
DOMPurify.addHook('beforeSanitizeAttributes', (node) => {
|
||||||
if (node instanceof Element && node.tagName === 'A' && node.hasAttribute('target')) {
|
if (node.tagName === 'A' && node.hasAttribute('target')) {
|
||||||
node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute('target') ?? '');
|
node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute('target') ?? '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
|
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
|
||||||
if (node instanceof Element && node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
||||||
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) ?? '');
|
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) ?? '');
|
||||||
node.removeAttribute(TEMPORARY_ATTRIBUTE);
|
node.removeAttribute(TEMPORARY_ATTRIBUTE);
|
||||||
if (node.getAttribute('target') === '_blank') {
|
if (node.getAttribute('target') === '_blank') {
|
||||||
|
@@ -167,7 +167,10 @@ export const getTasks = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const isInvalidDate = function (date, dateFormat, excludes, includes) {
|
export const isInvalidDate = function (date, dateFormat, excludes, includes) {
|
||||||
if (includes.includes(date.format(dateFormat.trim()))) {
|
const formattedDate = date.format(dateFormat.trim());
|
||||||
|
const dateOnly = date.format('YYYY-MM-DD');
|
||||||
|
|
||||||
|
if (includes.includes(formattedDate) || includes.includes(dateOnly)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
@@ -180,7 +183,7 @@ export const isInvalidDate = function (date, dateFormat, excludes, includes) {
|
|||||||
if (excludes.includes(date.format('dddd').toLowerCase())) {
|
if (excludes.includes(date.format('dddd').toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return excludes.includes(date.format(dateFormat.trim()));
|
return excludes.includes(formattedDate) || excludes.includes(dateOnly);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setWeekday = function (txt) {
|
export const setWeekday = function (txt) {
|
||||||
|
@@ -581,17 +581,11 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
|
|
||||||
rectangles
|
rectangles
|
||||||
.append('rect')
|
.append('rect')
|
||||||
.attr('id', function (d) {
|
.attr('id', (d) => 'exclude-' + d.start.format('YYYY-MM-DD'))
|
||||||
return 'exclude-' + d.start.format('YYYY-MM-DD');
|
.attr('x', (d) => timeScale(d.start.startOf('day')) + theSidePad)
|
||||||
})
|
|
||||||
.attr('x', function (d) {
|
|
||||||
return timeScale(d.start) + theSidePad;
|
|
||||||
})
|
|
||||||
.attr('y', conf.gridLineStartPadding)
|
.attr('y', conf.gridLineStartPadding)
|
||||||
.attr('width', function (d) {
|
.attr('width', (d) => timeScale(d.end.endOf('day')) - timeScale(d.start.startOf('day')))
|
||||||
const renderEnd = d.end.add(1, 'day');
|
|
||||||
return timeScale(renderEnd) - timeScale(d.start);
|
|
||||||
})
|
|
||||||
.attr('height', h - theTopPad - conf.gridLineStartPadding)
|
.attr('height', h - theTopPad - conf.gridLineStartPadding)
|
||||||
.attr('transform-origin', function (d, i) {
|
.attr('transform-origin', function (d, i) {
|
||||||
return (
|
return (
|
||||||
@@ -615,9 +609,20 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
* @param h
|
* @param h
|
||||||
*/
|
*/
|
||||||
function makeGrid(theSidePad, theTopPad, w, h) {
|
function makeGrid(theSidePad, theTopPad, w, h) {
|
||||||
|
const dateFormat = diagObj.db.getDateFormat();
|
||||||
|
const userAxisFormat = diagObj.db.getAxisFormat();
|
||||||
|
let axisFormat;
|
||||||
|
if (userAxisFormat) {
|
||||||
|
axisFormat = userAxisFormat;
|
||||||
|
} else if (dateFormat === 'D') {
|
||||||
|
axisFormat = '%d';
|
||||||
|
} else {
|
||||||
|
axisFormat = conf.axisFormat ?? '%Y-%m-%d';
|
||||||
|
}
|
||||||
|
|
||||||
let bottomXAxis = axisBottom(timeScale)
|
let bottomXAxis = axisBottom(timeScale)
|
||||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
||||||
.tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
|
.tickFormat(timeFormat(axisFormat));
|
||||||
|
|
||||||
const reTickInterval = /^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/;
|
const reTickInterval = /^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/;
|
||||||
const resultTickInterval = reTickInterval.exec(
|
const resultTickInterval = reTickInterval.exec(
|
||||||
@@ -669,7 +674,7 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
if (diagObj.db.topAxisEnabled() || conf.topAxis) {
|
if (diagObj.db.topAxisEnabled() || conf.topAxis) {
|
||||||
let topXAxis = axisTop(timeScale)
|
let topXAxis = axisTop(timeScale)
|
||||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
||||||
.tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
|
.tickFormat(timeFormat(axisFormat));
|
||||||
|
|
||||||
if (resultTickInterval !== null) {
|
if (resultTickInterval !== null) {
|
||||||
const every = resultTickInterval[1];
|
const every = resultTickInterval[1];
|
||||||
|
297
packages/mermaid/src/diagrams/mindmap/mindmapDb.getData.test.ts
Normal file
297
packages/mermaid/src/diagrams/mindmap/mindmapDb.getData.test.ts
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
|
import { MindmapDB } from './mindmapDb.js';
|
||||||
|
import type { MindmapLayoutNode, MindmapLayoutEdge } from './mindmapDb.js';
|
||||||
|
import type { Edge } from '../../rendering-util/types.js';
|
||||||
|
|
||||||
|
// Mock the getConfig function
|
||||||
|
vi.mock('../../diagram-api/diagramAPI.js', () => ({
|
||||||
|
getConfig: vi.fn(() => ({
|
||||||
|
mindmap: {
|
||||||
|
layoutAlgorithm: 'cose-bilkent',
|
||||||
|
padding: 10,
|
||||||
|
maxNodeWidth: 200,
|
||||||
|
useMaxWidth: true,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('MindmapDb getData function', () => {
|
||||||
|
let db: MindmapDB;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
db = new MindmapDB();
|
||||||
|
// Clear the database before each test
|
||||||
|
db.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getData', () => {
|
||||||
|
it('should return empty data when no mindmap is set', () => {
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
expect(result.nodes).toEqual([]);
|
||||||
|
expect(result.edges).toEqual([]);
|
||||||
|
expect(result.config).toBeDefined();
|
||||||
|
expect(result.rootNode).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return structured data for simple mindmap', () => {
|
||||||
|
// Create a simple mindmap structure
|
||||||
|
db.addNode(0, 'root', 'Root Node', 0);
|
||||||
|
db.addNode(1, 'child1', 'Child 1', 0);
|
||||||
|
db.addNode(1, 'child2', 'Child 2', 0);
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
expect(result.nodes).toHaveLength(3);
|
||||||
|
expect(result.edges).toHaveLength(2);
|
||||||
|
expect(result.config).toBeDefined();
|
||||||
|
expect(result.rootNode).toBeDefined();
|
||||||
|
|
||||||
|
// Check root node
|
||||||
|
const rootNode = (result.nodes as MindmapLayoutNode[]).find((n) => n.id === '0');
|
||||||
|
expect(rootNode).toBeDefined();
|
||||||
|
expect(rootNode?.label).toBe('Root Node');
|
||||||
|
expect(rootNode?.level).toBe(0);
|
||||||
|
|
||||||
|
// Check child nodes
|
||||||
|
const child1 = (result.nodes as MindmapLayoutNode[]).find((n) => n.id === '1');
|
||||||
|
expect(child1).toBeDefined();
|
||||||
|
expect(child1?.label).toBe('Child 1');
|
||||||
|
expect(child1?.level).toBe(1);
|
||||||
|
|
||||||
|
// Check edges
|
||||||
|
expect(result.edges).toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
start: '0',
|
||||||
|
end: '1',
|
||||||
|
depth: 0,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return structured data for hierarchical mindmap', () => {
|
||||||
|
// Create a hierarchical mindmap structure
|
||||||
|
db.addNode(0, 'root', 'Root Node', 0);
|
||||||
|
db.addNode(1, 'child1', 'Child 1', 0);
|
||||||
|
db.addNode(2, 'grandchild1', 'Grandchild 1', 0);
|
||||||
|
db.addNode(2, 'grandchild2', 'Grandchild 2', 0);
|
||||||
|
db.addNode(1, 'child2', 'Child 2', 0);
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
expect(result.nodes).toHaveLength(5);
|
||||||
|
expect(result.edges).toHaveLength(4);
|
||||||
|
|
||||||
|
// Check that all levels are represented
|
||||||
|
const levels = result.nodes.map((n) => (n as MindmapLayoutNode).level);
|
||||||
|
expect(levels).toContain(0); // root
|
||||||
|
expect(levels).toContain(1); // children
|
||||||
|
expect(levels).toContain(2); // grandchildren
|
||||||
|
|
||||||
|
// Check edge relationships
|
||||||
|
const edgeRelations = result.edges.map(
|
||||||
|
(e) => `${(e as MindmapLayoutEdge).start}->${(e as MindmapLayoutEdge).end}`
|
||||||
|
);
|
||||||
|
expect(edgeRelations).toContain('0->1'); // root to child1
|
||||||
|
expect(edgeRelations).toContain('1->2'); // child1 to grandchild1
|
||||||
|
expect(edgeRelations).toContain('1->3'); // child1 to grandchild2
|
||||||
|
expect(edgeRelations).toContain('0->4'); // root to child2
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should preserve node properties in processed data', () => {
|
||||||
|
// Add a node with specific properties
|
||||||
|
db.addNode(0, 'root', 'Root Node', 2); // type 2 = rectangle
|
||||||
|
|
||||||
|
// Set additional properties
|
||||||
|
const mindmap = db.getMindmap();
|
||||||
|
if (mindmap) {
|
||||||
|
mindmap.width = 150;
|
||||||
|
mindmap.height = 75;
|
||||||
|
mindmap.padding = 15;
|
||||||
|
mindmap.section = 1;
|
||||||
|
mindmap.class = 'custom-class';
|
||||||
|
mindmap.icon = 'star';
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
expect(result.nodes).toHaveLength(1);
|
||||||
|
const node = result.nodes[0] as MindmapLayoutNode;
|
||||||
|
|
||||||
|
expect(node.type).toBe(2);
|
||||||
|
expect(node.width).toBe(150);
|
||||||
|
expect(node.height).toBe(75);
|
||||||
|
expect(node.padding).toBe(15);
|
||||||
|
expect(node.section).toBeUndefined(); // Root node has undefined section
|
||||||
|
expect(node.cssClasses).toBe('mindmap-node section-root section--1 custom-class');
|
||||||
|
expect(node.icon).toBe('star');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should generate unique edge IDs', () => {
|
||||||
|
db.addNode(0, 'root', 'Root Node', 0);
|
||||||
|
db.addNode(1, 'child1', 'Child 1', 0);
|
||||||
|
db.addNode(1, 'child2', 'Child 2', 0);
|
||||||
|
db.addNode(1, 'child3', 'Child 3', 0);
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
const edgeIds = result.edges.map((e: Edge) => e.id);
|
||||||
|
const uniqueIds = new Set(edgeIds);
|
||||||
|
|
||||||
|
expect(edgeIds).toHaveLength(3);
|
||||||
|
expect(uniqueIds.size).toBe(3); // All IDs should be unique
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle nodes with missing optional properties', () => {
|
||||||
|
db.addNode(0, 'root', 'Root Node', 0);
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
const node = result.nodes[0] as MindmapLayoutNode;
|
||||||
|
|
||||||
|
// Should handle undefined/missing properties gracefully
|
||||||
|
expect(node.section).toBeUndefined(); // Root node has undefined section
|
||||||
|
expect(node.cssClasses).toBe('mindmap-node section-root section--1'); // Root node gets special classes
|
||||||
|
expect(node.icon).toBeUndefined();
|
||||||
|
expect(node.x).toBeUndefined();
|
||||||
|
expect(node.y).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should assign correct section classes based on sibling position', () => {
|
||||||
|
// Create the example mindmap structure:
|
||||||
|
// A
|
||||||
|
// a0
|
||||||
|
// aa0
|
||||||
|
// a1
|
||||||
|
// aaa
|
||||||
|
// a2
|
||||||
|
db.addNode(0, 'A', 'A', 0); // Root
|
||||||
|
db.addNode(1, 'a0', 'a0', 0); // First child of root
|
||||||
|
db.addNode(2, 'aa0', 'aa0', 0); // Child of a0
|
||||||
|
db.addNode(1, 'a1', 'a1', 0); // Second child of root
|
||||||
|
db.addNode(2, 'aaa', 'aaa', 0); // Child of a1
|
||||||
|
db.addNode(1, 'a2', 'a2', 0); // Third child of root
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
// Find nodes by their labels
|
||||||
|
const nodeA = result.nodes.find((n) => n.label === 'A') as MindmapLayoutNode;
|
||||||
|
const nodeA0 = result.nodes.find((n) => n.label === 'a0') as MindmapLayoutNode;
|
||||||
|
const nodeAa0 = result.nodes.find((n) => n.label === 'aa0') as MindmapLayoutNode;
|
||||||
|
const nodeA1 = result.nodes.find((n) => n.label === 'a1') as MindmapLayoutNode;
|
||||||
|
const nodeAaa = result.nodes.find((n) => n.label === 'aaa') as MindmapLayoutNode;
|
||||||
|
const nodeA2 = result.nodes.find((n) => n.label === 'a2') as MindmapLayoutNode;
|
||||||
|
|
||||||
|
// Check section assignments
|
||||||
|
expect(nodeA.section).toBeUndefined(); // Root has undefined section
|
||||||
|
expect(nodeA0.section).toBe(0); // First child of root
|
||||||
|
expect(nodeAa0.section).toBe(0); // Inherits from parent a0
|
||||||
|
expect(nodeA1.section).toBe(1); // Second child of root
|
||||||
|
expect(nodeAaa.section).toBe(1); // Inherits from parent a1
|
||||||
|
expect(nodeA2.section).toBe(2); // Third child of root
|
||||||
|
|
||||||
|
// Check CSS classes
|
||||||
|
expect(nodeA.cssClasses).toBe('mindmap-node section-root section--1');
|
||||||
|
expect(nodeA0.cssClasses).toBe('mindmap-node section-0');
|
||||||
|
expect(nodeAa0.cssClasses).toBe('mindmap-node section-0');
|
||||||
|
expect(nodeA1.cssClasses).toBe('mindmap-node section-1');
|
||||||
|
expect(nodeAaa.cssClasses).toBe('mindmap-node section-1');
|
||||||
|
expect(nodeA2.cssClasses).toBe('mindmap-node section-2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should preserve custom classes while adding section classes', () => {
|
||||||
|
db.addNode(0, 'root', 'Root Node', 0);
|
||||||
|
db.addNode(1, 'child', 'Child Node', 0);
|
||||||
|
|
||||||
|
// Add custom classes to nodes
|
||||||
|
const mindmap = db.getMindmap();
|
||||||
|
if (mindmap) {
|
||||||
|
mindmap.class = 'custom-root-class';
|
||||||
|
if (mindmap.children?.[0]) {
|
||||||
|
mindmap.children[0].class = 'custom-child-class';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
const rootNode = result.nodes.find((n) => n.label === 'Root Node') as MindmapLayoutNode;
|
||||||
|
const childNode = result.nodes.find((n) => n.label === 'Child Node') as MindmapLayoutNode;
|
||||||
|
|
||||||
|
// Should include both section classes and custom classes
|
||||||
|
expect(rootNode.cssClasses).toBe('mindmap-node section-root section--1 custom-root-class');
|
||||||
|
expect(childNode.cssClasses).toBe('mindmap-node section-0 custom-child-class');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not create any fake root nodes', () => {
|
||||||
|
// Create a simple mindmap
|
||||||
|
db.addNode(0, 'A', 'A', 0);
|
||||||
|
db.addNode(1, 'a0', 'a0', 0);
|
||||||
|
db.addNode(1, 'a1', 'a1', 0);
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
// Check that we only have the expected nodes
|
||||||
|
expect(result.nodes).toHaveLength(3);
|
||||||
|
expect(result.nodes.map((n) => n.label)).toEqual(['A', 'a0', 'a1']);
|
||||||
|
|
||||||
|
// Check that there's no node with label "mindmap" or any other fake root
|
||||||
|
const mindmapNode = result.nodes.find((n) => n.label === 'mindmap');
|
||||||
|
expect(mindmapNode).toBeUndefined();
|
||||||
|
|
||||||
|
// Verify the root node has the correct classes
|
||||||
|
const rootNode = result.nodes.find((n) => n.label === 'A') as MindmapLayoutNode;
|
||||||
|
expect(rootNode.cssClasses).toBe('mindmap-node section-root section--1');
|
||||||
|
expect(rootNode.level).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should assign correct section classes to edges', () => {
|
||||||
|
// Create the example mindmap structure:
|
||||||
|
// A
|
||||||
|
// a0
|
||||||
|
// aa0
|
||||||
|
// a1
|
||||||
|
// aaa
|
||||||
|
// a2
|
||||||
|
db.addNode(0, 'A', 'A', 0); // Root
|
||||||
|
db.addNode(1, 'a0', 'a0', 0); // First child of root
|
||||||
|
db.addNode(2, 'aa0', 'aa0', 0); // Child of a0
|
||||||
|
db.addNode(1, 'a1', 'a1', 0); // Second child of root
|
||||||
|
db.addNode(2, 'aaa', 'aaa', 0); // Child of a1
|
||||||
|
db.addNode(1, 'a2', 'a2', 0); // Third child of root
|
||||||
|
|
||||||
|
const result = db.getData();
|
||||||
|
|
||||||
|
// Should have 5 edges: A->a0, a0->aa0, A->a1, a1->aaa, A->a2
|
||||||
|
expect(result.edges).toHaveLength(5);
|
||||||
|
|
||||||
|
// Find edges by their start and end nodes
|
||||||
|
const edgeA_a0 = result.edges.find(
|
||||||
|
(e) => e.start === '0' && e.end === '1'
|
||||||
|
) as MindmapLayoutEdge;
|
||||||
|
const edgeA0_aa0 = result.edges.find(
|
||||||
|
(e) => e.start === '1' && e.end === '2'
|
||||||
|
) as MindmapLayoutEdge;
|
||||||
|
const edgeA_a1 = result.edges.find(
|
||||||
|
(e) => e.start === '0' && e.end === '3'
|
||||||
|
) as MindmapLayoutEdge;
|
||||||
|
const edgeA1_aaa = result.edges.find(
|
||||||
|
(e) => e.start === '3' && e.end === '4'
|
||||||
|
) as MindmapLayoutEdge;
|
||||||
|
const edgeA_a2 = result.edges.find(
|
||||||
|
(e) => e.start === '0' && e.end === '5'
|
||||||
|
) as MindmapLayoutEdge;
|
||||||
|
|
||||||
|
// Check edge classes
|
||||||
|
expect(edgeA_a0.classes).toBe('edge section-edge-0 edge-depth-1'); // A->a0: section-0, depth-1
|
||||||
|
expect(edgeA0_aa0.classes).toBe('edge section-edge-0 edge-depth-2'); // a0->aa0: section-0, depth-2
|
||||||
|
expect(edgeA_a1.classes).toBe('edge section-edge-1 edge-depth-1'); // A->a1: section-1, depth-1
|
||||||
|
expect(edgeA1_aaa.classes).toBe('edge section-edge-1 edge-depth-2'); // a1->aaa: section-1, depth-2
|
||||||
|
expect(edgeA_a2.classes).toBe('edge section-edge-2 edge-depth-1'); // A->a2: section-2, depth-1
|
||||||
|
|
||||||
|
// Check section assignments match the child nodes
|
||||||
|
expect(edgeA_a0.section).toBe(0);
|
||||||
|
expect(edgeA0_aa0.section).toBe(0);
|
||||||
|
expect(edgeA_a1.section).toBe(1);
|
||||||
|
expect(edgeA1_aaa.section).toBe(1);
|
||||||
|
expect(edgeA_a2.section).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -5,6 +5,22 @@ import { log } from '../../logger.js';
|
|||||||
import type { MindmapNode } from './mindmapTypes.js';
|
import type { MindmapNode } from './mindmapTypes.js';
|
||||||
import defaultConfig from '../../defaultConfig.js';
|
import defaultConfig from '../../defaultConfig.js';
|
||||||
|
|
||||||
|
import type { LayoutData, Node, Edge } from '../../rendering-util/types.js';
|
||||||
|
|
||||||
|
// Extend Node type for mindmap-specific properties
|
||||||
|
export type MindmapLayoutNode = Node & {
|
||||||
|
level: number;
|
||||||
|
nodeId: string;
|
||||||
|
type: number;
|
||||||
|
section?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extend Edge type for mindmap-specific properties
|
||||||
|
export type MindmapLayoutEdge = Edge & {
|
||||||
|
depth: number;
|
||||||
|
section?: number;
|
||||||
|
};
|
||||||
|
|
||||||
const nodeType = {
|
const nodeType = {
|
||||||
DEFAULT: 0,
|
DEFAULT: 0,
|
||||||
NO_BORDER: 0,
|
NO_BORDER: 0,
|
||||||
@@ -27,7 +43,6 @@ export class MindmapDB {
|
|||||||
this.nodeType = nodeType;
|
this.nodeType = nodeType;
|
||||||
this.clear();
|
this.clear();
|
||||||
this.getType = this.getType.bind(this);
|
this.getType = this.getType.bind(this);
|
||||||
this.getMindmap = this.getMindmap.bind(this);
|
|
||||||
this.getElementById = this.getElementById.bind(this);
|
this.getElementById = this.getElementById.bind(this);
|
||||||
this.getParent = this.getParent.bind(this);
|
this.getParent = this.getParent.bind(this);
|
||||||
this.getMindmap = this.getMindmap.bind(this);
|
this.getMindmap = this.getMindmap.bind(this);
|
||||||
@@ -156,6 +171,215 @@ export class MindmapDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign section numbers to nodes based on their position relative to root
|
||||||
|
* @param node - The mindmap node to process
|
||||||
|
* @param sectionNumber - The section number to assign (undefined for root)
|
||||||
|
*/
|
||||||
|
public assignSections(node: MindmapNode, sectionNumber?: number): void {
|
||||||
|
// For root node, section should be undefined (not -1)
|
||||||
|
if (node.level === 0) {
|
||||||
|
node.section = undefined;
|
||||||
|
} else {
|
||||||
|
// For non-root nodes, assign the section number
|
||||||
|
node.section = sectionNumber;
|
||||||
|
}
|
||||||
|
// For root node's children, assign section numbers based on their index
|
||||||
|
// For other nodes, inherit parent's section number
|
||||||
|
if (node.children) {
|
||||||
|
for (const [index, child] of node.children.entries()) {
|
||||||
|
const childSectionNumber = node.level === 0 ? index : sectionNumber;
|
||||||
|
this.assignSections(child, childSectionNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert mindmap tree structure to flat array of nodes
|
||||||
|
* @param node - The mindmap node to process
|
||||||
|
* @param processedNodes - Array to collect processed nodes
|
||||||
|
*/
|
||||||
|
public flattenNodes(node: MindmapNode, processedNodes: MindmapLayoutNode[]): void {
|
||||||
|
// Build CSS classes for the node
|
||||||
|
const cssClasses = ['mindmap-node'];
|
||||||
|
|
||||||
|
// Add section-specific classes
|
||||||
|
if (node.level === 0) {
|
||||||
|
// Root node gets special classes
|
||||||
|
cssClasses.push('section-root', 'section--1');
|
||||||
|
} else if (node.section !== undefined) {
|
||||||
|
// Child nodes get section class based on their section number
|
||||||
|
cssClasses.push(`section-${node.section}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add any custom classes from the node
|
||||||
|
if (node.class) {
|
||||||
|
cssClasses.push(node.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
const classes = cssClasses.join(' ');
|
||||||
|
|
||||||
|
// Map mindmap node type to valid shape name
|
||||||
|
const getShapeFromType = (type: number) => {
|
||||||
|
switch (type) {
|
||||||
|
case nodeType.CIRCLE:
|
||||||
|
return 'circle';
|
||||||
|
case nodeType.RECT:
|
||||||
|
return 'rect';
|
||||||
|
case nodeType.ROUNDED_RECT:
|
||||||
|
return 'rounded';
|
||||||
|
case nodeType.CLOUD:
|
||||||
|
return 'cloud';
|
||||||
|
case nodeType.BANG:
|
||||||
|
return 'bang';
|
||||||
|
case nodeType.HEXAGON:
|
||||||
|
return 'hexagon';
|
||||||
|
case nodeType.DEFAULT:
|
||||||
|
return 'defaultMindmapNode';
|
||||||
|
case nodeType.NO_BORDER:
|
||||||
|
default:
|
||||||
|
return 'rect';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const processedNode: MindmapLayoutNode = {
|
||||||
|
id: node.id.toString(),
|
||||||
|
domId: 'node_' + node.id.toString(),
|
||||||
|
label: node.descr,
|
||||||
|
isGroup: false,
|
||||||
|
shape: getShapeFromType(node.type),
|
||||||
|
width: node.width,
|
||||||
|
height: node.height ?? 0,
|
||||||
|
padding: node.padding,
|
||||||
|
cssClasses: classes,
|
||||||
|
cssStyles: [],
|
||||||
|
look: 'default',
|
||||||
|
icon: node.icon,
|
||||||
|
x: node.x,
|
||||||
|
y: node.y,
|
||||||
|
// Mindmap-specific properties
|
||||||
|
level: node.level,
|
||||||
|
nodeId: node.nodeId,
|
||||||
|
type: node.type,
|
||||||
|
section: node.section,
|
||||||
|
};
|
||||||
|
|
||||||
|
processedNodes.push(processedNode);
|
||||||
|
|
||||||
|
// Recursively process children
|
||||||
|
if (node.children) {
|
||||||
|
for (const child of node.children) {
|
||||||
|
this.flattenNodes(child, processedNodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate edges from parent-child relationships in mindmap tree
|
||||||
|
* @param node - The mindmap node to process
|
||||||
|
* @param edges - Array to collect edges
|
||||||
|
*/
|
||||||
|
public generateEdges(node: MindmapNode, edges: MindmapLayoutEdge[]): void {
|
||||||
|
if (!node.children) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const child of node.children) {
|
||||||
|
// Build CSS classes for the edge
|
||||||
|
let edgeClasses = 'edge';
|
||||||
|
|
||||||
|
// Add section-specific classes based on the child's section
|
||||||
|
if (child.section !== undefined) {
|
||||||
|
edgeClasses += ` section-edge-${child.section}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add depth class based on the parent's level + 1 (depth of the edge)
|
||||||
|
const edgeDepth = node.level + 1;
|
||||||
|
edgeClasses += ` edge-depth-${edgeDepth}`;
|
||||||
|
|
||||||
|
const edge: MindmapLayoutEdge = {
|
||||||
|
id: `edge_${node.id}_${child.id}`,
|
||||||
|
start: node.id.toString(),
|
||||||
|
end: child.id.toString(),
|
||||||
|
type: 'normal',
|
||||||
|
curve: 'basis',
|
||||||
|
thickness: 'normal',
|
||||||
|
look: 'default',
|
||||||
|
classes: edgeClasses,
|
||||||
|
// Store mindmap-specific data
|
||||||
|
depth: node.level,
|
||||||
|
section: child.section,
|
||||||
|
};
|
||||||
|
|
||||||
|
edges.push(edge);
|
||||||
|
|
||||||
|
// Recursively process child edges
|
||||||
|
this.generateEdges(child, edges);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get structured data for layout algorithms
|
||||||
|
* Following the pattern established by ER diagrams
|
||||||
|
* @returns Structured data containing nodes, edges, and config
|
||||||
|
*/
|
||||||
|
public getData(): LayoutData {
|
||||||
|
const mindmapRoot = this.getMindmap();
|
||||||
|
const config = getConfig();
|
||||||
|
|
||||||
|
if (!mindmapRoot) {
|
||||||
|
return {
|
||||||
|
nodes: [],
|
||||||
|
edges: [],
|
||||||
|
config,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
log.debug('getData: mindmapRoot', mindmapRoot, config);
|
||||||
|
|
||||||
|
// Assign section numbers to all nodes based on their position relative to root
|
||||||
|
this.assignSections(mindmapRoot);
|
||||||
|
|
||||||
|
// Convert tree structure to flat arrays
|
||||||
|
const processedNodes: MindmapLayoutNode[] = [];
|
||||||
|
const processedEdges: MindmapLayoutEdge[] = [];
|
||||||
|
|
||||||
|
this.flattenNodes(mindmapRoot, processedNodes);
|
||||||
|
this.generateEdges(mindmapRoot, processedEdges);
|
||||||
|
|
||||||
|
log.debug(
|
||||||
|
`getData: processed ${processedNodes.length} nodes and ${processedEdges.length} edges`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create shapes map for ELK compatibility
|
||||||
|
const shapes = new Map<string, any>();
|
||||||
|
for (const node of processedNodes) {
|
||||||
|
shapes.set(node.id, {
|
||||||
|
shape: node.shape,
|
||||||
|
width: node.width,
|
||||||
|
height: node.height,
|
||||||
|
padding: node.padding,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
nodes: processedNodes,
|
||||||
|
edges: processedEdges,
|
||||||
|
config,
|
||||||
|
// Store the root node for mindmap-specific layout algorithms
|
||||||
|
rootNode: mindmapRoot,
|
||||||
|
// Properties required by dagre layout algorithm
|
||||||
|
markers: [], // Mindmaps don't use markers
|
||||||
|
direction: 'TB', // Top-to-bottom direction for mindmaps
|
||||||
|
nodeSpacing: 50, // Default spacing between nodes
|
||||||
|
rankSpacing: 50, // Default spacing between ranks
|
||||||
|
// Add shapes for ELK compatibility
|
||||||
|
shapes: Object.fromEntries(shapes),
|
||||||
|
// Additional properties that layout algorithms might expect
|
||||||
|
type: 'mindmap',
|
||||||
|
diagramId: 'mindmap-' + Date.now(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expose logger to grammar
|
||||||
public getLogger() {
|
public getLogger() {
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
@@ -1,200 +1,94 @@
|
|||||||
import cytoscape from 'cytoscape';
|
|
||||||
// @ts-expect-error No types available
|
|
||||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
|
||||||
import { select } from 'd3';
|
|
||||||
import type { MermaidConfig } from '../../config.type.js';
|
|
||||||
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
||||||
import type { DrawDefinition } from '../../diagram-api/types.js';
|
import type { DrawDefinition } from '../../diagram-api/types.js';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import type { D3Element } from '../../types.js';
|
import { getDiagramElement } from '../../rendering-util/insertElementsForSize.js';
|
||||||
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
import { getRegisteredLayoutAlgorithm, render } from '../../rendering-util/render.js';
|
||||||
import { setupGraphViewbox } from '../../setupGraphViewbox.js';
|
import { setupViewPortForSVG } from '../../rendering-util/setupViewPortForSVG.js';
|
||||||
import type { FilledMindMapNode, MindmapNode } from './mindmapTypes.js';
|
import type { LayoutData } from '../../rendering-util/types.js';
|
||||||
import { drawNode, positionNode } from './svgDraw.js';
|
import type { FilledMindMapNode } from './mindmapTypes.js';
|
||||||
|
import { drawNode } from './svgDraw.js';
|
||||||
import defaultConfig from '../../defaultConfig.js';
|
import defaultConfig from '../../defaultConfig.js';
|
||||||
import type { MindmapDB } from './mindmapDb.js';
|
import type { MindmapDB } from './mindmapDb.js';
|
||||||
// Inject the layout algorithm into cytoscape
|
|
||||||
cytoscape.use(coseBilkent);
|
|
||||||
|
|
||||||
async function drawNodes(
|
async function _drawNodes(
|
||||||
db: MindmapDB,
|
db: MindmapDB,
|
||||||
svg: D3Element,
|
svg: any,
|
||||||
mindmap: FilledMindMapNode,
|
mindmap: FilledMindMapNode,
|
||||||
section: number,
|
section: number,
|
||||||
conf: MermaidConfig
|
conf: any
|
||||||
) {
|
) {
|
||||||
await drawNode(db, svg, mindmap, section, conf);
|
await drawNode(db, svg, mindmap, section, conf);
|
||||||
if (mindmap.children) {
|
if (mindmap.children) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
mindmap.children.map((child, index) =>
|
mindmap.children.map((child, index) =>
|
||||||
drawNodes(db, svg, child, section < 0 ? index : section, conf)
|
_drawNodes(db, svg, child, section < 0 ? index : section, conf)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'cytoscape' {
|
/**
|
||||||
interface EdgeSingular {
|
* Update the layout data with actual node dimensions after drawing
|
||||||
_private: {
|
*/
|
||||||
bodyBounds: unknown;
|
function _updateNodeDimensions(data4Layout: LayoutData, mindmapRoot: FilledMindMapNode) {
|
||||||
rscratch: {
|
const updateNode = (node: FilledMindMapNode) => {
|
||||||
startX: number;
|
// Find the corresponding node in the layout data
|
||||||
startY: number;
|
const layoutNode = data4Layout.nodes.find((n) => n.id === node.id.toString());
|
||||||
midX: number;
|
if (layoutNode) {
|
||||||
midY: number;
|
// Update with the actual dimensions calculated by drawNode
|
||||||
endX: number;
|
layoutNode.width = node.width;
|
||||||
endY: number;
|
layoutNode.height = node.height;
|
||||||
|
log.debug('Updated node dimensions:', node.id, 'width:', node.width, 'height:', node.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively update children
|
||||||
|
if (node.children) {
|
||||||
|
node.children.forEach(updateNode);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawEdges(edgesEl: D3Element, cy: cytoscape.Core) {
|
updateNode(mindmapRoot);
|
||||||
cy.edges().map((edge, id) => {
|
|
||||||
const data = edge.data();
|
|
||||||
if (edge[0]._private.bodyBounds) {
|
|
||||||
const bounds = edge[0]._private.rscratch;
|
|
||||||
log.trace('Edge: ', id, data);
|
|
||||||
edgesEl
|
|
||||||
.insert('path')
|
|
||||||
.attr(
|
|
||||||
'd',
|
|
||||||
`M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} `
|
|
||||||
)
|
|
||||||
.attr('class', 'edge section-edge-' + data.section + ' edge-depth-' + data.depth);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function addNodes(mindmap: MindmapNode, cy: cytoscape.Core, conf: MermaidConfig, level: number) {
|
|
||||||
cy.add({
|
|
||||||
group: 'nodes',
|
|
||||||
data: {
|
|
||||||
id: mindmap.id.toString(),
|
|
||||||
labelText: mindmap.descr,
|
|
||||||
height: mindmap.height,
|
|
||||||
width: mindmap.width,
|
|
||||||
level: level,
|
|
||||||
nodeId: mindmap.id,
|
|
||||||
padding: mindmap.padding,
|
|
||||||
type: mindmap.type,
|
|
||||||
},
|
|
||||||
position: {
|
|
||||||
x: mindmap.x!,
|
|
||||||
y: mindmap.y!,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (mindmap.children) {
|
|
||||||
mindmap.children.forEach((child) => {
|
|
||||||
addNodes(child, cy, conf, level + 1);
|
|
||||||
cy.add({
|
|
||||||
group: 'edges',
|
|
||||||
data: {
|
|
||||||
id: `${mindmap.id}_${child.id}`,
|
|
||||||
source: mindmap.id,
|
|
||||||
target: child.id,
|
|
||||||
depth: level,
|
|
||||||
section: child.section,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function layoutMindmap(node: MindmapNode, conf: MermaidConfig): Promise<cytoscape.Core> {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
// Add temporary render element
|
|
||||||
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
|
||||||
const cy = cytoscape({
|
|
||||||
container: document.getElementById('cy'), // container to render in
|
|
||||||
style: [
|
|
||||||
{
|
|
||||||
selector: 'edge',
|
|
||||||
style: {
|
|
||||||
'curve-style': 'bezier',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
// Remove element after layout
|
|
||||||
renderEl.remove();
|
|
||||||
addNodes(node, cy, conf, 0);
|
|
||||||
|
|
||||||
// Make cytoscape care about the dimensions of the nodes
|
|
||||||
cy.nodes().forEach(function (n) {
|
|
||||||
n.layoutDimensions = () => {
|
|
||||||
const data = n.data();
|
|
||||||
return { w: data.width, h: data.height };
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
cy.layout({
|
|
||||||
name: 'cose-bilkent',
|
|
||||||
// @ts-ignore Types for cose-bilkent are not correct?
|
|
||||||
quality: 'proof',
|
|
||||||
styleEnabled: false,
|
|
||||||
animate: false,
|
|
||||||
}).run();
|
|
||||||
cy.ready((e) => {
|
|
||||||
log.info('Ready', e);
|
|
||||||
resolve(cy);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function positionNodes(db: MindmapDB, cy: cytoscape.Core) {
|
|
||||||
cy.nodes().map((node, id) => {
|
|
||||||
const data = node.data();
|
|
||||||
data.x = node.position().x;
|
|
||||||
data.y = node.position().y;
|
|
||||||
positionNode(db, data);
|
|
||||||
const el = db.getElementById(data.nodeId);
|
|
||||||
log.info('id:', id, 'Position: (', node.position().x, ', ', node.position().y, ')', data);
|
|
||||||
el.attr(
|
|
||||||
'transform',
|
|
||||||
`translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})`
|
|
||||||
);
|
|
||||||
el.attr('attr', `apa-${id})`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const draw: DrawDefinition = async (text, id, _version, diagObj) => {
|
export const draw: DrawDefinition = async (text, id, _version, diagObj) => {
|
||||||
log.debug('Rendering mindmap diagram\n' + text);
|
log.debug('Rendering mindmap diagram\n' + text);
|
||||||
|
const { securityLevel, mindmap: conf, layout } = getConfig();
|
||||||
|
|
||||||
|
// Draw the nodes first to get their dimensions, then update the layout data
|
||||||
const db = diagObj.db as MindmapDB;
|
const db = diagObj.db as MindmapDB;
|
||||||
|
|
||||||
|
// The getData method provided in all supported diagrams is used to extract the data from the parsed structure
|
||||||
|
// into the Layout data format
|
||||||
|
const data4Layout = db.getData();
|
||||||
|
|
||||||
|
// Create the root SVG - the element is the div containing the SVG element
|
||||||
|
const svg = getDiagramElement(id, securityLevel);
|
||||||
|
|
||||||
|
data4Layout.type = diagObj.type;
|
||||||
|
data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(layout, {
|
||||||
|
fallback: 'cose-bilkent',
|
||||||
|
});
|
||||||
|
// For mindmap diagrams, prioritize mindmap-specific layout algorithm configuration
|
||||||
|
|
||||||
|
data4Layout.diagramId = id;
|
||||||
|
|
||||||
|
// Ensure required properties are set for compatibility with different layout algorithms
|
||||||
|
data4Layout.markers = ['point'];
|
||||||
|
data4Layout.direction = 'TB';
|
||||||
|
|
||||||
const mm = db.getMindmap();
|
const mm = db.getMindmap();
|
||||||
if (!mm) {
|
if (!mm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const conf = getConfig();
|
// Use the unified rendering system
|
||||||
conf.htmlLabels = false;
|
await render(data4Layout, svg);
|
||||||
|
|
||||||
const svg = selectSvgElement(id);
|
|
||||||
|
|
||||||
// Draw the graph and start with drawing the nodes without proper position
|
|
||||||
// this gives us the size of the nodes and we can set the positions later
|
|
||||||
|
|
||||||
const edgesElem = svg.append('g');
|
|
||||||
edgesElem.attr('class', 'mindmap-edges');
|
|
||||||
const nodesElem = svg.append('g');
|
|
||||||
nodesElem.attr('class', 'mindmap-nodes');
|
|
||||||
await drawNodes(db, nodesElem, mm as FilledMindMapNode, -1, conf);
|
|
||||||
|
|
||||||
// Next step is to layout the mindmap, giving each node a position
|
|
||||||
|
|
||||||
const cy = await layoutMindmap(mm, conf);
|
|
||||||
|
|
||||||
// After this we can draw, first the edges and the then nodes with the correct position
|
|
||||||
drawEdges(edgesElem, cy);
|
|
||||||
positionNodes(db, cy);
|
|
||||||
|
|
||||||
// Setup the view box and size of the svg element
|
// Setup the view box and size of the svg element
|
||||||
setupGraphViewbox(
|
setupViewPortForSVG(
|
||||||
undefined,
|
|
||||||
svg,
|
svg,
|
||||||
conf.mindmap?.padding ?? defaultConfig.mindmap.padding,
|
conf?.padding ?? defaultConfig.mindmap.padding,
|
||||||
conf.mindmap?.useMaxWidth ?? defaultConfig.mindmap.useMaxWidth
|
'mindmapDiagram',
|
||||||
|
conf?.useMaxWidth ?? defaultConfig.mindmap.useMaxWidth
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -64,6 +64,9 @@ const getStyles: DiagramStylesProvider = (options) =>
|
|||||||
.section-root text {
|
.section-root text {
|
||||||
fill: ${options.gitBranchLabel0};
|
fill: ${options.gitBranchLabel0};
|
||||||
}
|
}
|
||||||
|
.section-root span {
|
||||||
|
color: ${options.gitBranchLabel0};
|
||||||
|
}
|
||||||
.icon-container {
|
.icon-container {
|
||||||
height:100%;
|
height:100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@@ -139,6 +139,32 @@ describe('pie', () => {
|
|||||||
}).rejects.toThrowError();
|
}).rejects.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle simple pie with zero slice value', async () => {
|
||||||
|
await parser.parse(`pie title Default text position: Animal adoption
|
||||||
|
accTitle: simple pie char demo
|
||||||
|
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
||||||
|
"dogs" : 0
|
||||||
|
"rats" : 40.12
|
||||||
|
`);
|
||||||
|
|
||||||
|
const sections = db.getSections();
|
||||||
|
expect(sections.get('dogs')).toBe(0);
|
||||||
|
expect(sections.get('rats')).toBe(40.12);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle simple pie with negative slice value', async () => {
|
||||||
|
await expect(async () => {
|
||||||
|
await parser.parse(`pie title Default text position: Animal adoption
|
||||||
|
accTitle: simple pie char demo
|
||||||
|
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
||||||
|
"dogs" : -60.67
|
||||||
|
"rats" : 40.12
|
||||||
|
`);
|
||||||
|
}).rejects.toThrowError(
|
||||||
|
'"dogs" has invalid value: -60.67. Negative values are not allowed in pie charts. All slice values must be >= 0.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle unsafe properties', async () => {
|
it('should handle unsafe properties', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
parser.parse(`pie title Unsafe props test
|
parser.parse(`pie title Unsafe props test
|
||||||
|
@@ -34,6 +34,11 @@ const clear = (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addSection = ({ label, value }: D3Section): void => {
|
const addSection = ({ label, value }: D3Section): void => {
|
||||||
|
if (value < 0) {
|
||||||
|
throw new Error(
|
||||||
|
`"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!sections.has(label)) {
|
if (!sections.has(label)) {
|
||||||
sections.set(label, value);
|
sections.set(label, value);
|
||||||
log.debug(`added new section: ${label}, with value: ${value}`);
|
log.debug(`added new section: ${label}, with value: ${value}`);
|
||||||
|
@@ -10,20 +10,14 @@ import { cleanAndMerge, parseFontSize } from '../../utils.js';
|
|||||||
import type { D3Section, PieDB, Sections } from './pieTypes.js';
|
import type { D3Section, PieDB, Sections } from './pieTypes.js';
|
||||||
|
|
||||||
const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Section>[] => {
|
const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Section>[] => {
|
||||||
// Compute the position of each group on the pie:
|
const sum = [...sections.values()].reduce((acc, val) => acc + val, 0);
|
||||||
|
|
||||||
const pieData: D3Section[] = [...sections.entries()]
|
const pieData: D3Section[] = [...sections.entries()]
|
||||||
.map((element: [string, number]): D3Section => {
|
.map(([label, value]) => ({ label, value }))
|
||||||
return {
|
.filter((d) => (d.value / sum) * 100 >= 1) // Remove values < 1%
|
||||||
label: element[0],
|
.sort((a, b) => b.value - a.value);
|
||||||
value: element[1],
|
|
||||||
};
|
const pie: d3.Pie<unknown, D3Section> = d3pie<D3Section>().value((d) => d.value);
|
||||||
})
|
|
||||||
.sort((a: D3Section, b: D3Section): number => {
|
|
||||||
return b.value - a.value;
|
|
||||||
});
|
|
||||||
const pie: d3.Pie<unknown, D3Section> = d3pie<D3Section>().value(
|
|
||||||
(d3Section: D3Section): number => d3Section.value
|
|
||||||
);
|
|
||||||
return pie(pieData);
|
return pie(pieData);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,13 +83,21 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
themeVariables.pie11,
|
themeVariables.pie11,
|
||||||
themeVariables.pie12,
|
themeVariables.pie12,
|
||||||
];
|
];
|
||||||
|
let sum = 0;
|
||||||
|
sections.forEach((section) => {
|
||||||
|
sum += section;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter out arcs that would render as 0%
|
||||||
|
const filteredArcs = arcs.filter((datum) => ((datum.data.value / sum) * 100).toFixed(0) !== '0');
|
||||||
|
|
||||||
// Set the color scale
|
// Set the color scale
|
||||||
const color: d3.ScaleOrdinal<string, 12, never> = scaleOrdinal(myGeneratedColors);
|
const color: d3.ScaleOrdinal<string, 12, never> = scaleOrdinal(myGeneratedColors);
|
||||||
|
|
||||||
// Build the pie chart: each part of the pie is a path that we build using the arc function.
|
// Build the pie chart: each part of the pie is a path that we build using the arc function.
|
||||||
group
|
group
|
||||||
.selectAll('mySlices')
|
.selectAll('mySlices')
|
||||||
.data(arcs)
|
.data(filteredArcs)
|
||||||
.enter()
|
.enter()
|
||||||
.append('path')
|
.append('path')
|
||||||
.attr('d', arcGenerator)
|
.attr('d', arcGenerator)
|
||||||
@@ -104,15 +106,11 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
})
|
})
|
||||||
.attr('class', 'pieCircle');
|
.attr('class', 'pieCircle');
|
||||||
|
|
||||||
let sum = 0;
|
|
||||||
sections.forEach((section) => {
|
|
||||||
sum += section;
|
|
||||||
});
|
|
||||||
// Now add the percentage.
|
// Now add the percentage.
|
||||||
// Use the centroid method to get the best coordinates.
|
// Use the centroid method to get the best coordinates.
|
||||||
group
|
group
|
||||||
.selectAll('mySlices')
|
.selectAll('mySlices')
|
||||||
.data(arcs)
|
.data(filteredArcs)
|
||||||
.enter()
|
.enter()
|
||||||
.append('text')
|
.append('text')
|
||||||
.text((datum: d3.PieArcDatum<D3Section>): string => {
|
.text((datum: d3.PieArcDatum<D3Section>): string => {
|
||||||
@@ -133,15 +131,20 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
.attr('class', 'pieTitleText');
|
.attr('class', 'pieTitleText');
|
||||||
|
|
||||||
// Add the legends/annotations for each section
|
// Add the legends/annotations for each section
|
||||||
|
const allSectionData: D3Section[] = [...sections.entries()].map(([label, value]) => ({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
}));
|
||||||
|
|
||||||
const legend = group
|
const legend = group
|
||||||
.selectAll('.legend')
|
.selectAll('.legend')
|
||||||
.data(color.domain())
|
.data(allSectionData)
|
||||||
.enter()
|
.enter()
|
||||||
.append('g')
|
.append('g')
|
||||||
.attr('class', 'legend')
|
.attr('class', 'legend')
|
||||||
.attr('transform', (_datum, index: number): string => {
|
.attr('transform', (_datum, index: number): string => {
|
||||||
const height = LEGEND_RECT_SIZE + LEGEND_SPACING;
|
const height = LEGEND_RECT_SIZE + LEGEND_SPACING;
|
||||||
const offset = (height * color.domain().length) / 2;
|
const offset = (height * allSectionData.length) / 2;
|
||||||
const horizontal = 12 * LEGEND_RECT_SIZE;
|
const horizontal = 12 * LEGEND_RECT_SIZE;
|
||||||
const vertical = index * height - offset;
|
const vertical = index * height - offset;
|
||||||
return 'translate(' + horizontal + ',' + vertical + ')';
|
return 'translate(' + horizontal + ',' + vertical + ')';
|
||||||
@@ -151,20 +154,18 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
.append('rect')
|
.append('rect')
|
||||||
.attr('width', LEGEND_RECT_SIZE)
|
.attr('width', LEGEND_RECT_SIZE)
|
||||||
.attr('height', LEGEND_RECT_SIZE)
|
.attr('height', LEGEND_RECT_SIZE)
|
||||||
.style('fill', color)
|
.style('fill', (d) => color(d.label))
|
||||||
.style('stroke', color);
|
.style('stroke', (d) => color(d.label));
|
||||||
|
|
||||||
legend
|
legend
|
||||||
.data(arcs)
|
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('x', LEGEND_RECT_SIZE + LEGEND_SPACING)
|
.attr('x', LEGEND_RECT_SIZE + LEGEND_SPACING)
|
||||||
.attr('y', LEGEND_RECT_SIZE - LEGEND_SPACING)
|
.attr('y', LEGEND_RECT_SIZE - LEGEND_SPACING)
|
||||||
.text((datum: d3.PieArcDatum<D3Section>): string => {
|
.text((d) => {
|
||||||
const { label, value } = datum.data;
|
|
||||||
if (db.getShowData()) {
|
if (db.getShowData()) {
|
||||||
return `${label} [${value}]`;
|
return `${d.label} [${d.value}]`;
|
||||||
}
|
}
|
||||||
return label;
|
return d.label;
|
||||||
});
|
});
|
||||||
|
|
||||||
const longestTextWidth = Math.max(
|
const longestTextWidth = Math.max(
|
||||||
|
@@ -27,6 +27,7 @@ TEXTDATA [\u0020-\u0021\u0023-\u002B\u002D-\u007E]
|
|||||||
%%
|
%%
|
||||||
|
|
||||||
<INITIAL>"sankey-beta" { this.pushState('csv'); return 'SANKEY'; }
|
<INITIAL>"sankey-beta" { this.pushState('csv'); return 'SANKEY'; }
|
||||||
|
<INITIAL>"sankey" { this.pushState('csv'); return 'SANKEY'; }
|
||||||
<INITIAL,csv><<EOF>> { return 'EOF' } // match end of file
|
<INITIAL,csv><<EOF>> { return 'EOF' } // match end of file
|
||||||
<INITIAL,csv>({CRLF}|{LF}) { return 'NEWLINE' }
|
<INITIAL,csv>({CRLF}|{LF}) { return 'NEWLINE' }
|
||||||
<INITIAL,csv>{COMMA} { return 'COMMA' }
|
<INITIAL,csv>{COMMA} { return 'COMMA' }
|
||||||
|
@@ -13,7 +13,7 @@ describe('Sankey diagram', function () {
|
|||||||
sankey.parser.yy.clear();
|
sankey.parser.yy.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses csv', () => {
|
it('parses csv with sankey-beta syntax', () => {
|
||||||
const csv = path.resolve(__dirname, './energy.csv');
|
const csv = path.resolve(__dirname, './energy.csv');
|
||||||
const data = fs.readFileSync(csv, 'utf8');
|
const data = fs.readFileSync(csv, 'utf8');
|
||||||
const graphDefinition = prepareTextForParsing(cleanupComments('sankey-beta\n\n ' + data));
|
const graphDefinition = prepareTextForParsing(cleanupComments('sankey-beta\n\n ' + data));
|
||||||
@@ -21,7 +21,15 @@ describe('Sankey diagram', function () {
|
|||||||
sankey.parser.parse(graphDefinition);
|
sankey.parser.parse(graphDefinition);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows __proto__ as id', function () {
|
it('parses csv with sankey syntax', () => {
|
||||||
|
const csv = path.resolve(__dirname, './energy.csv');
|
||||||
|
const data = fs.readFileSync(csv, 'utf8');
|
||||||
|
const graphDefinition = prepareTextForParsing(cleanupComments('sankey\n\n ' + data));
|
||||||
|
|
||||||
|
sankey.parser.parse(graphDefinition);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows __proto__ as id with sankey-beta syntax', function () {
|
||||||
sankey.parser.parse(
|
sankey.parser.parse(
|
||||||
prepareTextForParsing(`sankey-beta
|
prepareTextForParsing(`sankey-beta
|
||||||
__proto__,A,0.597
|
__proto__,A,0.597
|
||||||
@@ -29,5 +37,14 @@ describe('Sankey diagram', function () {
|
|||||||
`)
|
`)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('allows __proto__ as id with sankey syntax', function () {
|
||||||
|
sankey.parser.parse(
|
||||||
|
prepareTextForParsing(`sankey
|
||||||
|
__proto__,A,0.597
|
||||||
|
A,__proto__,0.403
|
||||||
|
`)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -3,7 +3,7 @@ import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-a
|
|||||||
const id = 'sankey';
|
const id = 'sankey';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
return /^\s*sankey-beta/.test(txt);
|
return /^\s*sankey(-beta)?/.test(txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
"actor" { this.begin('ID'); return 'participant_actor'; }
|
"actor" { this.begin('ID'); return 'participant_actor'; }
|
||||||
"create" return 'create';
|
"create" return 'create';
|
||||||
"destroy" { this.begin('ID'); return 'destroy'; }
|
"destroy" { this.begin('ID'); return 'destroy'; }
|
||||||
<ID>[^\<->\->:\n,;]+?([\-]*[^\<->\->:\n,;]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
<ID>[^<\->\->:\n,;]+?([\-]*[^<\->\->:\n,;]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
||||||
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
||||||
<ALIAS>(?:) { this.popState(); this.popState(); return 'NEWLINE'; }
|
<ALIAS>(?:) { this.popState(); this.popState(); return 'NEWLINE'; }
|
||||||
"loop" { this.begin('LINE'); return 'loop'; }
|
"loop" { this.begin('LINE'); return 'loop'; }
|
||||||
@@ -73,7 +73,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
"off" return 'off';
|
"off" return 'off';
|
||||||
"," return ',';
|
"," return ',';
|
||||||
";" return 'NEWLINE';
|
";" return 'NEWLINE';
|
||||||
[^\+\<->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)))[\-]*[^\+\<->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
|
[^+<\->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)))[\-]*[^\+<\->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
|
||||||
"->>" return 'SOLID_ARROW';
|
"->>" return 'SOLID_ARROW';
|
||||||
"<<->>" return 'BIDIRECTIONAL_SOLID_ARROW';
|
"<<->>" return 'BIDIRECTIONAL_SOLID_ARROW';
|
||||||
"-->>" return 'DOTTED_ARROW';
|
"-->>" return 'DOTTED_ARROW';
|
||||||
|
@@ -350,6 +350,26 @@ Bob-->Alice-in-Wonderland:I am good thanks!`);
|
|||||||
expect(messages[1].from).toBe('Bob');
|
expect(messages[1].from).toBe('Bob');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle equals in participant names', async () => {
|
||||||
|
const diagram = await Diagram.fromText(`
|
||||||
|
sequenceDiagram
|
||||||
|
participant Alice=Wonderland
|
||||||
|
participant Bob
|
||||||
|
Alice=Wonderland->Bob:Hello Bob, how are - you?
|
||||||
|
Bob-->Alice=Wonderland:I am good thanks!`);
|
||||||
|
|
||||||
|
const actors = diagram.db.getActors();
|
||||||
|
expect([...actors.keys()]).toEqual(['Alice=Wonderland', 'Bob']);
|
||||||
|
expect(actors.get('Alice=Wonderland').description).toBe('Alice=Wonderland');
|
||||||
|
expect(actors.get('Bob').description).toBe('Bob');
|
||||||
|
|
||||||
|
const messages = diagram.db.getMessages();
|
||||||
|
|
||||||
|
expect(messages.length).toBe(2);
|
||||||
|
expect(messages[0].from).toBe('Alice=Wonderland');
|
||||||
|
expect(messages[1].from).toBe('Bob');
|
||||||
|
});
|
||||||
|
|
||||||
it('should alias participants', async () => {
|
it('should alias participants', async () => {
|
||||||
const diagram = await Diagram.fromText(`
|
const diagram = await Diagram.fromText(`
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
@@ -1348,7 +1368,7 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
|||||||
it('should handle box without description', async () => {
|
it('should handle box without description', async () => {
|
||||||
const diagram = await Diagram.fromText(`
|
const diagram = await Diagram.fromText(`
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
box Aqua
|
box aqua
|
||||||
participant a as Alice
|
participant a as Alice
|
||||||
participant b as Bob
|
participant b as Bob
|
||||||
end
|
end
|
||||||
@@ -1364,7 +1384,7 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
|||||||
const boxes = diagram.db.getBoxes();
|
const boxes = diagram.db.getBoxes();
|
||||||
expect(boxes[0].name).toBeFalsy();
|
expect(boxes[0].name).toBeFalsy();
|
||||||
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
||||||
expect(boxes[0].fill).toEqual('Aqua');
|
expect(boxes[0].fill).toEqual('aqua');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle simple actor creation', async () => {
|
it('should handle simple actor creation', async () => {
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
import type { DiagramDB } from '../../diagram-api/types.js';
|
|
||||||
import type { UsecaseDiagramConfig, UsecaseNode } from './types.js';
|
|
||||||
import { cleanAndMerge } from '../../utils.js';
|
|
||||||
|
|
||||||
export class UsecaseDiagramDB implements DiagramDB {
|
|
||||||
public getNodes() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public getConfig() {
|
|
||||||
return cleanAndMerge({}) as Required<UsecaseDiagramConfig>;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addNode(node: UsecaseNode, level: number) {
|
|
||||||
if (level === 0) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRoot() {
|
|
||||||
return { name: '', children: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
public addClass(_id: string, _style: string) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
public getClasses() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
public getStylesForClass(_classSelector: string) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
public clear() {
|
|
||||||
// commonClear();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
import type {
|
|
||||||
DiagramDetector,
|
|
||||||
DiagramLoader,
|
|
||||||
ExternalDiagramDefinition,
|
|
||||||
} from '../../diagram-api/types.js';
|
|
||||||
|
|
||||||
const id = 'usecase';
|
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
|
||||||
return /^\s*usecase/.test(txt);
|
|
||||||
};
|
|
||||||
|
|
||||||
const loader: DiagramLoader = async () => {
|
|
||||||
const { diagram } = await import('./diagram.js');
|
|
||||||
return { id, diagram };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const usecase: ExternalDiagramDefinition = {
|
|
||||||
id,
|
|
||||||
detector,
|
|
||||||
loader,
|
|
||||||
};
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user