mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-24 01:39:53 +02:00
Fix for fixed position
This commit is contained in:
@@ -121,22 +121,22 @@
|
||||
S --> T: angrepp
|
||||
T --> U: Apa
|
||||
T --> V: Varg
|
||||
C
|
||||
D
|
||||
E
|
||||
|
||||
B
|
||||
C
|
||||
D
|
||||
`;
|
||||
code = `
|
||||
stateDiagram
|
||||
A0
|
||||
state subbe {
|
||||
subState
|
||||
B
|
||||
}
|
||||
C
|
||||
D
|
||||
E
|
||||
`;
|
||||
// code = `
|
||||
// stateDiagram
|
||||
// A0
|
||||
// state subbe {
|
||||
// subState
|
||||
// B
|
||||
// }
|
||||
// C
|
||||
// D
|
||||
// E
|
||||
// `;
|
||||
|
||||
let positions = {
|
||||
nodes: {
|
||||
@@ -182,10 +182,10 @@
|
||||
},
|
||||
};
|
||||
|
||||
positions = {
|
||||
nodes: {},
|
||||
edges: {},
|
||||
};
|
||||
// positions = {
|
||||
// nodes: {},
|
||||
// edges: {},
|
||||
// };
|
||||
|
||||
const { svg } = await mermaid.render('the-id-of-the-svg', code, undefined, positions);
|
||||
// if (window?.calcIntersections) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"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.",
|
||||
"type": "module",
|
||||
"module": "./dist/mermaid.core.mjs",
|
||||
|
@@ -123,10 +123,10 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
||||
for (const child of children) {
|
||||
const width = child.width || 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);
|
||||
// log.info(
|
||||
// 'STO node child 2',
|
||||
// 'BBB node child 2',
|
||||
// child.id,
|
||||
// positions.nodes[child.id].x,
|
||||
// positions.nodes[child.id].y
|
||||
@@ -136,16 +136,20 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
||||
minYP = Math.min(positions.nodes[child.id].y - height / 2, minYP);
|
||||
maxYP = Math.max(positions.nodes[child.id].y + height / 2, maxYP);
|
||||
}
|
||||
positions.nodes[node.id] = {
|
||||
x: minX + (maxX - minX) / 2 - 5,
|
||||
y: maxY + 15,
|
||||
width: maxX - minX + 20,
|
||||
height: maxYP - minYP + 30,
|
||||
};
|
||||
if (!positions.nodes[node.id]) {
|
||||
positions.nodes[node.id] = {
|
||||
x: minX + (maxX - minX) / 2,
|
||||
y: maxY + 15,
|
||||
width: maxX - minX + 20,
|
||||
height: maxYP - minYP + 30,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Simple case
|
||||
positions.nodes[node.id] = { x: xPos, y: maxY + 20 };
|
||||
xPos = xPos + 75;
|
||||
if (!positions.nodes[node.id]) {
|
||||
// Simple case
|
||||
positions.nodes[node.id] = { x: xPos, y: maxY + 20 };
|
||||
xPos = xPos + 75;
|
||||
}
|
||||
}
|
||||
}
|
||||
data4Layout.nodes.map(function (node) {
|
||||
|
Reference in New Issue
Block a user