diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index ef696a8f7..189407909 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -121,6 +121,9 @@ export const addVertices = function(vert, g, svgId) { case 'diamond': _shape = 'question'; break; + case 'hexagon': + _shape = 'hexagon'; + break; case 'odd': _shape = 'rect_left_inv_arrow'; break; @@ -358,6 +361,37 @@ export const draw = function(text, id) { return shapeSvg; }; + render.shapes().hexagon = function(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const s = (w + h) * 0.9; + const points = [ + { x: s / 4, y: 0 }, + { x: (3 * s) / 4, y: 0 }, + { x: s, y: -s / 2 }, + { x: (3 * s) / 4, y: -s }, + { x: s / 4, y: -s }, + { x: 0, y: -s / 2 } + ]; + const shapeSvg = parent + .insert('polygon', ':first-child') + .attr( + 'points', + points + .map(function(d) { + return d.x + ',' + d.y; + }) + .join(' ') + ) + .attr('rx', 5) + .attr('ry', 5) + .attr('transform', 'translate(' + -s / 2 + ',' + (s * 2) / 4 + ')'); + node.intersect = function(point) { + return dagreD3.intersect.polygon(node, points, point); + }; + return shapeSvg; + }; + // Add custom shape for box with inverted arrow on left side render.shapes().rect_left_inv_arrow = function(parent, bbox, node) { const w = bbox.width; diff --git a/src/diagrams/flowchart/parser/flow.jison b/src/diagrams/flowchart/parser/flow.jison index bdc8d2869..da86b50f8 100644 --- a/src/diagrams/flowchart/parser/flow.jison +++ b/src/diagrams/flowchart/parser/flow.jison @@ -313,6 +313,10 @@ vertex: idString SQS text SQE {$$ = $1;yy.addVertex($1,$3,'diamond');} | idString DIAMOND_START text DIAMOND_STOP spaceList {$$ = $1;yy.addVertex($1,$3,'diamond');} + | idString DIAMOND_START DIAMOND_START text DIAMOND_STOP DIAMOND_STOP + {$$ = $1;yy.addVertex($1,$4,'hexagon');} + | idString DIAMOND_START DIAMOND_START text DIAMOND_STOP DIAMOND_STOP spaceList + {$$ = $1;yy.addVertex($1,$4,'hexagon');} | idString TAGEND text SQE {$$ = $1;yy.addVertex($1,$3,'odd');} | idString TAGEND text SQE spaceList