add shape datastore (for nodes of data flow diagram)

See https://github.com/mermaid-js/mermaid/issues/1893
This commit is contained in:
Michael Maier
2021-10-09 16:21:57 +02:00
parent cefafba062
commit cd427ab8ba
2 changed files with 23 additions and 0 deletions

View File

@@ -176,6 +176,24 @@ function subroutine(parent, bbox, node) {
return shapeSvg; return shapeSvg;
} }
function datastore(parent, bbox, node) {
const shapeSvg = parent
.insert('rect', ':first-child')
.attr('class', 'basic label-container')
.attr('style', node.style)
.attr('rx', node.rx)
.attr('ry', node.ry)
.attr('x', -bbox.width / 2)
.attr('y', -bbox.height / 2)
.attr('width', bbox.width)
.attr('height', bbox.height)
.attr('stroke-dasharray', bbox.width + ' ' + bbox.height);
node.intersect = function (point) {
return dagreD3.intersect.rect(node, point);
};
return shapeSvg;
}
function cylinder(parent, bbox, node) { function cylinder(parent, bbox, node) {
const w = bbox.width; const w = bbox.width;
const rx = w / 2; const rx = w / 2;
@@ -244,6 +262,7 @@ export function addToRender(render) {
render.shapes().hexagon = hexagon; render.shapes().hexagon = hexagon;
render.shapes().stadium = stadium; render.shapes().stadium = stadium;
render.shapes().subroutine = subroutine; render.shapes().subroutine = subroutine;
render.shapes().datastore = datastore;
render.shapes().cylinder = cylinder; render.shapes().cylinder = cylinder;
// Add custom shape for box with inverted arrow on left side // Add custom shape for box with inverted arrow on left side
@@ -270,6 +289,7 @@ export function addToRenderV2(addShape) {
addShape({ hexagon }); addShape({ hexagon });
addShape({ stadium }); addShape({ stadium });
addShape({ subroutine }); addShape({ subroutine });
addShape({ datastore });
addShape({ cylinder }); addShape({ cylinder });
// Add custom shape for box with inverted arrow on left side // Add custom shape for box with inverted arrow on left side

View File

@@ -123,6 +123,9 @@ export const addVertices = function (vert, g, svgId) {
case 'subroutine': case 'subroutine':
_shape = 'subroutine'; _shape = 'subroutine';
break; break;
case 'datastore':
_shape = 'datastore';
break;
case 'cylinder': case 'cylinder':
_shape = 'cylinder'; _shape = 'cylinder';
break; break;