diff --git a/packages/mermaid/src/setupGraphViewbox.js b/packages/mermaid/src/setupGraphViewbox.js index ba74b79fdd..d3df6db7cf 100644 --- a/packages/mermaid/src/setupGraphViewbox.js +++ b/packages/mermaid/src/setupGraphViewbox.js @@ -44,6 +44,7 @@ export const configureSvgSize = function (svgElem, height, width, useMaxWidth) { const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); d3Attrs(svgElem, attrs); }; + export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) { const svgBounds = svgElem.node().getBBox(); const sWidth = svgBounds.width; @@ -55,26 +56,13 @@ export const setupGraphViewbox = function (graph, svgElem, padding, useMaxWidth) let height = 0; log.info(`Graph bounds: ${width}x${height}`, graph); - // let tx = 0; - // let ty = 0; - // if (sWidth > width) { - // tx = (sWidth - width) / 2 + padding; width = sWidth + padding * 2; - // } else { - // if (Math.abs(sWidth - width) >= 2 * padding + 1) { - // width = width - padding; - // } - // } - // if (sHeight > height) { - // ty = (sHeight - height) / 2 + padding; height = sHeight + padding * 2; - // } log.info(`Calculated bounds: ${width}x${height}`); configureSvgSize(svgElem, height, width, useMaxWidth); // Ensure the viewBox includes the whole svgBounds area with extra space for padding - // const vBox = `0 0 ${width} ${height}`; const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${ svgBounds.width + 2 * padding } ${svgBounds.height + 2 * padding}`;