mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 10:59:51 +02:00
Fix non-htmlLabels not being centered
This commit is contained in:
@@ -59,6 +59,13 @@ export async function erBox<T extends SVGGraphicsElement>(parent: D3Selection<T>
|
|||||||
node.width = config.er!.minEntityWidth;
|
node.width = config.er!.minEntityWidth;
|
||||||
}
|
}
|
||||||
const shapeSvg = await drawRect(parent, node, options);
|
const shapeSvg = await drawRect(parent, node, options);
|
||||||
|
|
||||||
|
// drawRect doesn't center non-htmlLabels correctly as of now, so translate label
|
||||||
|
if (!evaluate(config.htmlLabels)) {
|
||||||
|
const textElement = shapeSvg.select('text');
|
||||||
|
const bbox = (textElement.node() as SVGTextElement)?.getBBox();
|
||||||
|
textElement.attr('transform', `translate(${-bbox.width / 2}, 0)`);
|
||||||
|
}
|
||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user