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