mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-22 00:40:22 +02:00
Merge branch 'neo-new-shapes' into perb-fix-circles-resize
This commit is contained in:
@@ -153,6 +153,7 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
// Add positions for nodes that lack them
|
// Add positions for nodes that lack them
|
||||||
let xPos = 0;
|
let xPos = 0;
|
||||||
function calculatePosition(node, positions, childDB) {
|
function calculatePosition(node, positions, childDB) {
|
||||||
|
// console.log('STO calculatePosition', node.id, maxY);
|
||||||
const children = childDB.get(node.id) || [];
|
const children = childDB.get(node.id) || [];
|
||||||
// log.info('STO calculatePosition', node.id, children.length);
|
// log.info('STO calculatePosition', node.id, children.length);
|
||||||
// We have a subgraph without position
|
// We have a subgraph without position
|
||||||
@@ -162,15 +163,16 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
let minYP = 10000;
|
let minYP = 10000;
|
||||||
let maxYP = -10000;
|
let maxYP = -10000;
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
const width = child.width || 50;
|
const width = child.width || 150;
|
||||||
const height = child.height || 50;
|
const height = child.height || 50;
|
||||||
// log.info('BBB 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(
|
// console.log(
|
||||||
// 'BBB node child 2',
|
// 'STO 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,
|
||||||
|
// positions.nodes[child.id].width
|
||||||
// );
|
// );
|
||||||
minX = Math.min(positions.nodes[child.id].x - width / 2, minX);
|
minX = Math.min(positions.nodes[child.id].x - width / 2, minX);
|
||||||
maxX = Math.max(positions.nodes[child.id].x + width / 2, maxX);
|
maxX = Math.max(positions.nodes[child.id].x + width / 2, maxX);
|
||||||
@@ -178,9 +180,19 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
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]) {
|
if (!positions.nodes[node.id]) {
|
||||||
|
// console.log(
|
||||||
|
// 'STO calculatePosition SUBGRAPH SIZE',
|
||||||
|
// node.id,
|
||||||
|
// 'y:',
|
||||||
|
// maxY - 10,
|
||||||
|
// 'minX:',
|
||||||
|
// minX,
|
||||||
|
// 'maxX:',
|
||||||
|
// maxX
|
||||||
|
// );
|
||||||
positions.nodes[node.id] = {
|
positions.nodes[node.id] = {
|
||||||
x: minX + (maxX - minX) / 2,
|
x: minX + (maxX - minX) / 2,
|
||||||
y: maxY + 15,
|
y: maxY + 120,
|
||||||
width: maxX - minX + 20,
|
width: maxX - minX + 20,
|
||||||
height: maxYP - minYP + 30,
|
height: maxYP - minYP + 30,
|
||||||
};
|
};
|
||||||
@@ -188,6 +200,7 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
} else {
|
} else {
|
||||||
if (!positions.nodes[node.id]) {
|
if (!positions.nodes[node.id]) {
|
||||||
// Simple case
|
// Simple case
|
||||||
|
// console.log('STO calculatePosition NODE SIZE', node.id, xPos, maxY, 'y:', maxY + 120);
|
||||||
positions.nodes[node.id] = { x: xPos, y: maxY + 120 };
|
positions.nodes[node.id] = { x: xPos, y: maxY + 120 };
|
||||||
xPos = xPos + 175;
|
xPos = xPos + 175;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user