mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-24 17:59:39 +02:00
Fix for fixed position
This commit is contained in:
@@ -121,22 +121,22 @@
|
|||||||
S --> T: angrepp
|
S --> T: angrepp
|
||||||
T --> U: Apa
|
T --> U: Apa
|
||||||
T --> V: Varg
|
T --> V: Varg
|
||||||
|
|
||||||
B
|
|
||||||
C
|
|
||||||
D
|
|
||||||
`;
|
|
||||||
code = `
|
|
||||||
stateDiagram
|
|
||||||
A0
|
|
||||||
state subbe {
|
|
||||||
subState
|
|
||||||
B
|
|
||||||
}
|
|
||||||
C
|
C
|
||||||
D
|
D
|
||||||
E
|
E
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
// code = `
|
||||||
|
// stateDiagram
|
||||||
|
// A0
|
||||||
|
// state subbe {
|
||||||
|
// subState
|
||||||
|
// B
|
||||||
|
// }
|
||||||
|
// C
|
||||||
|
// D
|
||||||
|
// E
|
||||||
|
// `;
|
||||||
|
|
||||||
let positions = {
|
let positions = {
|
||||||
nodes: {
|
nodes: {
|
||||||
@@ -182,10 +182,10 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
positions = {
|
// positions = {
|
||||||
nodes: {},
|
// nodes: {},
|
||||||
edges: {},
|
// edges: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
const { svg } = await mermaid.render('the-id-of-the-svg', code, undefined, positions);
|
const { svg } = await mermaid.render('the-id-of-the-svg', code, undefined, positions);
|
||||||
// if (window?.calcIntersections) {
|
// if (window?.calcIntersections) {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mermaid-chart/mermaid",
|
"name": "@mermaid-chart/mermaid",
|
||||||
"version": "11.0.2-b.3",
|
"version": "11.0.2-b.4",
|
||||||
"description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.",
|
"description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "./dist/mermaid.core.mjs",
|
"module": "./dist/mermaid.core.mjs",
|
||||||
|
@@ -123,10 +123,10 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
const width = child.width || 50;
|
const width = child.width || 50;
|
||||||
const height = child.height || 50;
|
const height = child.height || 50;
|
||||||
// log.info('STO node child 1', child.id, width, height);
|
// log.info('BBB node child 1', child.id, width, height);
|
||||||
calculatePosition(child, positions, childDB);
|
calculatePosition(child, positions, childDB);
|
||||||
// log.info(
|
// log.info(
|
||||||
// 'STO node child 2',
|
// 'BBB node child 2',
|
||||||
// child.id,
|
// child.id,
|
||||||
// positions.nodes[child.id].x,
|
// positions.nodes[child.id].x,
|
||||||
// positions.nodes[child.id].y
|
// positions.nodes[child.id].y
|
||||||
@@ -136,18 +136,22 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
minYP = Math.min(positions.nodes[child.id].y - height / 2, minYP);
|
minYP = Math.min(positions.nodes[child.id].y - height / 2, minYP);
|
||||||
maxYP = Math.max(positions.nodes[child.id].y + height / 2, maxYP);
|
maxYP = Math.max(positions.nodes[child.id].y + height / 2, maxYP);
|
||||||
}
|
}
|
||||||
|
if (!positions.nodes[node.id]) {
|
||||||
positions.nodes[node.id] = {
|
positions.nodes[node.id] = {
|
||||||
x: minX + (maxX - minX) / 2 - 5,
|
x: minX + (maxX - minX) / 2,
|
||||||
y: maxY + 15,
|
y: maxY + 15,
|
||||||
width: maxX - minX + 20,
|
width: maxX - minX + 20,
|
||||||
height: maxYP - minYP + 30,
|
height: maxYP - minYP + 30,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (!positions.nodes[node.id]) {
|
||||||
// Simple case
|
// Simple case
|
||||||
positions.nodes[node.id] = { x: xPos, y: maxY + 20 };
|
positions.nodes[node.id] = { x: xPos, y: maxY + 20 };
|
||||||
xPos = xPos + 75;
|
xPos = xPos + 75;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
data4Layout.nodes.map(function (node) {
|
data4Layout.nodes.map(function (node) {
|
||||||
if (!node.parentId) {
|
if (!node.parentId) {
|
||||||
calculatePosition(node, positions, childDB);
|
calculatePosition(node, positions, childDB);
|
||||||
|
Reference in New Issue
Block a user