mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#1295 Adding support for forks and joins
This commit is contained in:
parent
5662c06a33
commit
fd37edc53f
@ -49,14 +49,21 @@
|
||||
}
|
||||
</div>
|
||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||
stateDiagram-v2
|
||||
State1: This a a single line description
|
||||
State2: This a a multi line description
|
||||
State2: here comes the multi part
|
||||
a
|
||||
[*] --> State1
|
||||
State1 --> State2
|
||||
State2 --> [*]
|
||||
stateDiagram-v2
|
||||
[*]-->TV
|
||||
|
||||
state TV {
|
||||
state fork_state <<fork>>
|
||||
[*] --> fork_state
|
||||
fork_state --> State2
|
||||
fork_state --> State3
|
||||
|
||||
state join_state <<join>>
|
||||
State2 --> join_state
|
||||
State3 --> join_state
|
||||
join_state --> State4
|
||||
State4 --> [*]
|
||||
}
|
||||
</div>
|
||||
<div class="mermaid2 mermaid-apa" style="width: 100%; height: 20%;">
|
||||
stateDiagram
|
||||
|
@ -320,12 +320,7 @@ const rectWithTitle = (parent, node) => {
|
||||
.attr('y', -bbox.height / 2 - halfPadding)
|
||||
.attr('width', bbox.width + 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
|
||||
.attr('class', 'divider')
|
||||
.attr('x1', -bbox.width / 2 - halfPadding)
|
||||
@ -408,6 +403,32 @@ const start = (parent, node) => {
|
||||
|
||||
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 shapeSvg = parent
|
||||
.insert('g')
|
||||
@ -453,7 +474,9 @@ const shapes = {
|
||||
cylinder,
|
||||
start,
|
||||
end,
|
||||
note
|
||||
note,
|
||||
fork: forkJoin,
|
||||
join: forkJoin
|
||||
};
|
||||
|
||||
let nodeElems = {};
|
||||
|
@ -42,6 +42,9 @@ const setupNode = (g, parent, node, altFlag) => {
|
||||
if (node.start === false) {
|
||||
shape = 'end';
|
||||
}
|
||||
if (node.type !== 'default') {
|
||||
shape = node.type;
|
||||
}
|
||||
|
||||
if (!nodeDb[node.id]) {
|
||||
nodeDb[node.id] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user