fix for triangle

This commit is contained in:
Ashish Jain
2024-09-28 12:35:01 +02:00
parent d9b2220085
commit d3b51e2282

View File

@@ -8,15 +8,31 @@ import { createPathFromPoints } from './util.js';
import { evaluate } from '../../../diagrams/common/common.js';
import { getConfig } from '../../../diagram-api/diagramAPI.js';
const MIN_HEIGHT = 25;
const MIN_WIDTH = 25;
export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles;
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
if (node.width || node.height) {
node.width = (node?.width ?? 0) - labelPaddingX * 4;
if (node.width < MIN_WIDTH) {
node.width = MIN_WIDTH;
}
node.height = node?.height ?? 0;
if (node.height < MIN_HEIGHT) {
node.height = MIN_HEIGHT;
}
}
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const useHtmlLabels = evaluate(getConfig().flowchart?.htmlLabels);
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const w = Math.max(bbox.width + (labelPaddingX ?? 0), node?.width ?? 0);
const w = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX;
const h = Math.max(w + bbox.height, node?.height ?? 0);
const tw = w + bbox.height;