mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 05:49:43 +02:00
#1295 Adding support for forks and joins
This commit is contained in:
@@ -49,14 +49,21 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
State1: This a a single line description
|
[*]-->TV
|
||||||
State2: This a a multi line description
|
|
||||||
State2: here comes the multi part
|
state TV {
|
||||||
a
|
state fork_state <<fork>>
|
||||||
[*] --> State1
|
[*] --> fork_state
|
||||||
State1 --> State2
|
fork_state --> State2
|
||||||
State2 --> [*]
|
fork_state --> State3
|
||||||
|
|
||||||
|
state join_state <<join>>
|
||||||
|
State2 --> join_state
|
||||||
|
State3 --> join_state
|
||||||
|
join_state --> State4
|
||||||
|
State4 --> [*]
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2 mermaid-apa" style="width: 100%; height: 20%;">
|
<div class="mermaid2 mermaid-apa" style="width: 100%; height: 20%;">
|
||||||
stateDiagram
|
stateDiagram
|
||||||
|
@@ -320,12 +320,7 @@ const rectWithTitle = (parent, node) => {
|
|||||||
.attr('y', -bbox.height / 2 - halfPadding)
|
.attr('y', -bbox.height / 2 - halfPadding)
|
||||||
.attr('width', bbox.width + node.padding)
|
.attr('width', bbox.width + node.padding)
|
||||||
.attr('height', bbox.height + node.padding);
|
.attr('height', bbox.height + node.padding);
|
||||||
// innerRect
|
|
||||||
// .attr('class', 'inner')
|
|
||||||
// .attr('x', -bbox.width / 2 - halfPadding)
|
|
||||||
// .attr('y', -bbox.height / 2 - halfPadding + titleBox.height + halfPadding)
|
|
||||||
// .attr('width', bbox.width + node.padding)
|
|
||||||
// .attr('height', bbox.height + node.padding - titleBox.height - halfPadding);
|
|
||||||
innerLine
|
innerLine
|
||||||
.attr('class', 'divider')
|
.attr('class', 'divider')
|
||||||
.attr('x1', -bbox.width / 2 - halfPadding)
|
.attr('x1', -bbox.width / 2 - halfPadding)
|
||||||
@@ -408,6 +403,32 @@ const start = (parent, node) => {
|
|||||||
|
|
||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const forkJoin = (parent, node) => {
|
||||||
|
const shapeSvg = parent
|
||||||
|
.insert('g')
|
||||||
|
.attr('class', 'node default')
|
||||||
|
.attr('id', node.id);
|
||||||
|
|
||||||
|
const shape = shapeSvg
|
||||||
|
.append('rect')
|
||||||
|
.style('stroke', 'black')
|
||||||
|
.style('fill', 'black')
|
||||||
|
.attr('x', -35)
|
||||||
|
.attr('y', -5)
|
||||||
|
.attr('width', 70)
|
||||||
|
.attr('height', 10)
|
||||||
|
.attr('class', 'fork-join');
|
||||||
|
|
||||||
|
updateNodeBounds(node, shape);
|
||||||
|
node.height = node.height + node.padding / 2;
|
||||||
|
node.intersect = function(point) {
|
||||||
|
return intersect.rect(node, point);
|
||||||
|
};
|
||||||
|
|
||||||
|
return shapeSvg;
|
||||||
|
};
|
||||||
|
|
||||||
const end = (parent, node) => {
|
const end = (parent, node) => {
|
||||||
const shapeSvg = parent
|
const shapeSvg = parent
|
||||||
.insert('g')
|
.insert('g')
|
||||||
@@ -453,7 +474,9 @@ const shapes = {
|
|||||||
cylinder,
|
cylinder,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
note
|
note,
|
||||||
|
fork: forkJoin,
|
||||||
|
join: forkJoin
|
||||||
};
|
};
|
||||||
|
|
||||||
let nodeElems = {};
|
let nodeElems = {};
|
||||||
|
@@ -42,6 +42,9 @@ const setupNode = (g, parent, node, altFlag) => {
|
|||||||
if (node.start === false) {
|
if (node.start === false) {
|
||||||
shape = 'end';
|
shape = 'end';
|
||||||
}
|
}
|
||||||
|
if (node.type !== 'default') {
|
||||||
|
shape = node.type;
|
||||||
|
}
|
||||||
|
|
||||||
if (!nodeDb[node.id]) {
|
if (!nodeDb[node.id]) {
|
||||||
nodeDb[node.id] = {
|
nodeDb[node.id] = {
|
||||||
|
Reference in New Issue
Block a user