mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-08 00:29:39 +02:00
Updated triangle and slopedRect
This commit is contained in:
@@ -49,7 +49,10 @@ export const slopedRect = async (parent: SVGAElement, node: Node) => {
|
||||
}
|
||||
|
||||
polygon.attr('transform', `translate(0, ${h / 4})`);
|
||||
label.attr('transform', `translate(${-w / 2 + (node.padding ?? 0)}, ${-(node.padding ?? 0)})`);
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-w / 2 + (node.padding ?? 0)}, ${-h / 4 + (node.padding ?? 0)})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, polygon);
|
||||
|
||||
|
@@ -14,12 +14,14 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
||||
node.labelStyle = labelStyles;
|
||||
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding + 20;
|
||||
const h = (Math.sqrt(3) / 2) * w + (node.padding ?? 0);
|
||||
const w = bbox.width + (node.padding ?? 0);
|
||||
const h = w + bbox.height;
|
||||
|
||||
const tw = w + bbox.height;
|
||||
const points = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: w, y: 0 },
|
||||
{ x: w / 2, y: -h },
|
||||
{ x: tw, y: 0 },
|
||||
{ x: tw / 2, y: -h },
|
||||
];
|
||||
|
||||
const { cssStyles } = node;
|
||||
@@ -36,7 +38,7 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
||||
|
||||
const polygon = shapeSvg
|
||||
.insert(() => roughNode, ':first-child')
|
||||
.attr('transform', `translate(${-w / 2}, ${h / 2})`);
|
||||
.attr('transform', `translate(${-h / 2}, ${h / 2})`);
|
||||
|
||||
if (cssStyles) {
|
||||
polygon.attr('style', cssStyles);
|
||||
|
Reference in New Issue
Block a user