fix: placement

This commit is contained in:
IlyaDoronin 2023-10-25 12:13:18 +03:00
parent 7b48d51c77
commit b888d6b7f0
2 changed files with 26 additions and 28 deletions

@ -32,7 +32,7 @@ const stylesheet: Stylesheet[] = [
width: 30,
"line-color": "#DEDFE7",
"curve-style": "taxi",
"taxi-direction": "vertical",
"taxi-direction": "horizontal",
"taxi-turn": 60,
},
},
@ -46,8 +46,7 @@ const stylesheet: Stylesheet[] = [
},
];
export const Graph = () => {
return (
export const Graph = () => (
<Box
sx={{
padding: "20px",
@ -66,4 +65,3 @@ export const Graph = () => {
/>
</Box>
);
};

@ -22,16 +22,16 @@ const getEmptyVerticesAboveAmount = (
currentIndent: number,
level: number
): number => {
let leftIndent = indent + currentIndent;
let topIndent = indent + currentIndent;
return elements.filter(({ data, position }) => {
const isEmptyVertex =
position?.x === leftIndent &&
position?.y === level * 250 - 250 &&
position?.y === topIndent &&
position?.x === level * 250 - 250 &&
vertices.find((item) => item.id === data.id && !item.edges?.length);
if (isEmptyVertex) {
leftIndent += 200;
topIndent += 200;
}
return isEmptyVertex;
@ -63,8 +63,8 @@ export const createGraphElements = (
elements.push({
data: { id, label },
position: {
x: indent + currentIndent,
y: level * 250,
x: level * 250,
y: indent + currentIndent,
},
});