diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts index e24d5edfc..1e1e6ab00 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts @@ -12,21 +12,14 @@ export const circle = async (parent: SVGAElement, node: Node): Promise { const { themeVariables } = getConfig(); const { useGradient } = themeVariables; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts index a1d31a9ce..29b404b6a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts @@ -13,21 +13,15 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt // also check if the width or height is less than minimum default values (50), // if so set it to min value if (node.width || node.height) { - node.width = (node?.width ?? 0) - options.labelPaddingX * 2; - if (node.width < 20) { - node.width = 20; - } - - node.height = (node?.height ?? 0) - options.labelPaddingY * 2; - if (node.height < 10) { - node.height = 10; - } + node.width = (node?.width ?? 10) - options.labelPaddingX * 2; + node.height = (node?.height ?? 10) - options.labelPaddingY * 2; } const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); - const totalWidth = Math.max(bbox.width, node?.width || 0) + options.labelPaddingX * 2; - const totalHeight = Math.max(bbox.height, node?.height || 0) + options.labelPaddingY * 2; + const totalWidth = (node?.width ? node?.width : bbox.width) + options.labelPaddingX * 2; + const totalHeight = (node?.height ? node?.height : bbox.height) + options.labelPaddingY * 2; + const x = -totalWidth / 2; const y = -totalHeight / 2; let rect; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts index 2adb9a795..d2cba62cd 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts @@ -15,20 +15,13 @@ export const rect_left_inv_arrow = async ( const labelPaddingY = node.look === 'neo' ? nodePadding * 1.5 : (node.padding ?? 0); if (node.width || node.height) { - node.width = (node?.width ?? 0) - labelPaddingX * 2; - if (node.width < 50) { - node.width = 50; - } - - node.height = (node?.height ?? 0) - labelPaddingY * 2; - if (node.height < 50) { - node.height = 50; - } + node.width = (node?.width ?? 10) - labelPaddingX * 2; + node.height = (node?.height ?? 10) - labelPaddingY * 2; } const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); - const w = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX * 2; - const h = Math.max(bbox.height, node?.height ?? 0) + labelPaddingY * 2; + const w = (node?.width ? node?.width : bbox.width) + labelPaddingX * 2; + const h = (node?.height ? node?.height : bbox.height) + labelPaddingY * 2; const x = -w / 2; const y = -h / 2; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts index 6fdb1ca5d..fee56e893 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts @@ -62,8 +62,8 @@ export const stadium = async (parent: SVGAElement, node: Node) => { // if so set it to min value if (node.width || node.height) { node.width = (node?.width ?? 0) - labelPaddingX * 2; - if (node.width < 20) { - node.width = 20; + if (node.width < 10) { + node.width = 10; } node.height = (node?.height ?? 0) - labelPaddingY * 2; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts index 070d3e8d9..ded0fc5a3 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts @@ -50,14 +50,14 @@ export const subroutine = async (parent: SVGAElement, node: Node) => { // also check if the width or height is less than minimum default values (50), // if so set it to min value if (node.width || node.height) { - node.width = Math.max((node?.width ?? 0) - labelPaddingX - 2 * FRAME_WIDTH, 50); - node.height = Math.max((node?.height ?? 0) - labelPaddingY, 50); + node.width = Math.max((node?.width ?? 0) - labelPaddingX - 2 * FRAME_WIDTH, 10); + node.height = Math.max((node?.height ?? 0) - labelPaddingY, 10); } const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); - const totalWidth = Math.max(bbox.width, node?.width || 0) + 2 * FRAME_WIDTH + labelPaddingX; - const totalHeight = Math.max(bbox.height, node?.height || 0) + labelPaddingY; + const totalWidth = (node?.width ? node?.width : bbox.width) + 2 * FRAME_WIDTH + labelPaddingX; + const totalHeight = (node?.height ? node?.height : bbox.height) + labelPaddingY; const w = totalWidth - 2 * FRAME_WIDTH; const h = totalHeight;