#5237 Elk curve fix

This commit is contained in:
Knut Sveidqvist
2024-05-31 11:55:26 +02:00
parent 4266b2e4ca
commit 2c9c3b4571
2 changed files with 26 additions and 22 deletions

View File

@@ -468,8 +468,8 @@ export const render = async (data4Layout, svg, element, algorithm) => {
'elk.layered.mergeEdges': data4Layout.config.mergeEdges, 'elk.layered.mergeEdges': data4Layout.config.mergeEdges,
'elk.direction': 'DOWN', 'elk.direction': 'DOWN',
'spacing.baseValue': 30, 'spacing.baseValue': 30,
'spacing.nodeNode': 40, // 'spacing.nodeNode': 40,
'spacing.nodeNodeBetweenLayers': 45, // 'spacing.nodeNodeBetweenLayers': 45,
// 'spacing.edgeNode': 40, // 'spacing.edgeNode': 40,
// 'spacing.edgeNodeBetweenLayers': 30, // 'spacing.edgeNodeBetweenLayers': 30,
// 'spacing.edgeEdge': 30, // 'spacing.edgeEdge': 30,

View File

@@ -436,34 +436,38 @@ const fixCorners = function (lineData) {
// Find a new point on the line point 5 points back and push it to the new array // Find a new point on the line point 5 points back and push it to the new array
const newPrevPoint = findAdjacentPoint(prevPoint, cornerPoint, 5); const newPrevPoint = findAdjacentPoint(prevPoint, cornerPoint, 5);
const newNextPoint = findAdjacentPoint(nextPoint, cornerPoint, 5); const newNextPoint = findAdjacentPoint(nextPoint, cornerPoint, 5);
newLineData.push(newPrevPoint);
const xDiff = newNextPoint.x - newPrevPoint.x; const xDiff = newNextPoint.x - newPrevPoint.x;
const yDiff = newNextPoint.y - newPrevPoint.y; const yDiff = newNextPoint.y - newPrevPoint.y;
newLineData.push(newPrevPoint);
const a = Math.sqrt(2) * 2; const a = Math.sqrt(2) * 2;
let newCornerPoint = { x: cornerPoint.x, y: cornerPoint.y }; let newCornerPoint = { x: cornerPoint.x, y: cornerPoint.y };
if (cornerPoint.x === newPrevPoint.x) { if (Math.abs(nextPoint.x - prevPoint.x) > 10 && Math.abs(nextPoint.y - prevPoint.y) >= 10) {
// if (yDiff > 0) { console.log(
newCornerPoint = { 'Corner point fixing',
x: xDiff < 0 ? newPrevPoint.x - 5 + a : newPrevPoint.x + 5 - a, Math.abs(nextPoint.x - prevPoint.x),
y: yDiff < 0 ? newPrevPoint.y - a : newPrevPoint.y + a, Math.abs(nextPoint.y - prevPoint.y)
}; );
// } else { const r = 3;
// newCornerPoint = { x: newPrevPoint.x - a, y: newPrevPoint.y + a }; if (cornerPoint.x === newPrevPoint.x) {
// } newCornerPoint = {
x: xDiff < 0 ? newPrevPoint.x - r + a : newPrevPoint.x + r - a,
y: yDiff < 0 ? newPrevPoint.y - a : newPrevPoint.y + a,
};
} else {
newCornerPoint = {
x: xDiff < 0 ? newPrevPoint.x - a : newPrevPoint.x + a,
y: yDiff < 0 ? newPrevPoint.y - r + a : newPrevPoint.y + r - a,
};
}
} else { } else {
// if (yDiff > 0) { console.log(
// newCornerPoint = { x: newPrevPoint.x - 5 + a, y: newPrevPoint.y + a }; 'Corner point skipping fixing',
// } else { Math.abs(nextPoint.x - prevPoint.x),
newCornerPoint = { Math.abs(nextPoint.y - prevPoint.y)
x: xDiff < 0 ? newPrevPoint.x - a : newPrevPoint.x + a, );
y: yDiff < 0 ? newPrevPoint.y - 5 + a : newPrevPoint.y + 5 - a,
};
// }
} }
// newLineData.push(cornerPoint);
newLineData.push(newCornerPoint, newNextPoint); newLineData.push(newCornerPoint, newNextPoint);
} else { } else {
newLineData.push(lineData[i]); newLineData.push(lineData[i]);