fix: placement
This commit is contained in:
parent
7b48d51c77
commit
b888d6b7f0
@ -32,7 +32,7 @@ const stylesheet: Stylesheet[] = [
|
|||||||
width: 30,
|
width: 30,
|
||||||
"line-color": "#DEDFE7",
|
"line-color": "#DEDFE7",
|
||||||
"curve-style": "taxi",
|
"curve-style": "taxi",
|
||||||
"taxi-direction": "vertical",
|
"taxi-direction": "horizontal",
|
||||||
"taxi-turn": 60,
|
"taxi-turn": 60,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -46,8 +46,7 @@ const stylesheet: Stylesheet[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const Graph = () => {
|
export const Graph = () => (
|
||||||
return (
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
padding: "20px",
|
padding: "20px",
|
||||||
@ -65,5 +64,4 @@ export const Graph = () => {
|
|||||||
stylesheet={stylesheet}
|
stylesheet={stylesheet}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|||||||
@ -22,16 +22,16 @@ const getEmptyVerticesAboveAmount = (
|
|||||||
currentIndent: number,
|
currentIndent: number,
|
||||||
level: number
|
level: number
|
||||||
): number => {
|
): number => {
|
||||||
let leftIndent = indent + currentIndent;
|
let topIndent = indent + currentIndent;
|
||||||
|
|
||||||
return elements.filter(({ data, position }) => {
|
return elements.filter(({ data, position }) => {
|
||||||
const isEmptyVertex =
|
const isEmptyVertex =
|
||||||
position?.x === leftIndent &&
|
position?.y === topIndent &&
|
||||||
position?.y === level * 250 - 250 &&
|
position?.x === level * 250 - 250 &&
|
||||||
vertices.find((item) => item.id === data.id && !item.edges?.length);
|
vertices.find((item) => item.id === data.id && !item.edges?.length);
|
||||||
|
|
||||||
if (isEmptyVertex) {
|
if (isEmptyVertex) {
|
||||||
leftIndent += 200;
|
topIndent += 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isEmptyVertex;
|
return isEmptyVertex;
|
||||||
@ -63,8 +63,8 @@ export const createGraphElements = (
|
|||||||
elements.push({
|
elements.push({
|
||||||
data: { id, label },
|
data: { id, label },
|
||||||
position: {
|
position: {
|
||||||
x: indent + currentIndent,
|
x: level * 250,
|
||||||
y: level * 250,
|
y: indent + currentIndent,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user