-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fix loading and prepare objects to be placed on canvas by algor…
…ithm
- Loading branch information
1 parent
2afdff6
commit bea1ab5
Showing
14 changed files
with
442 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const nodeHeight = 240; | ||
const nodeWidth = 120; | ||
|
||
export function fruchtermanReingold(nodes, edges) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { fruchtermanReingold } from "./graph/fruchrein.js"; | ||
|
||
function objectToNode(object) { | ||
const edges = []; | ||
|
||
const oneToManyRelations = object.oneToManyRelations ?? {}; | ||
const oneToOneRelations = object.oneToOneRelations ?? {}; | ||
const associations = object.associations ?? {}; | ||
|
||
for (const link of Object.values(oneToOneRelations)) { | ||
edges.push(link); | ||
} | ||
|
||
for (const link of Object.values(associations)) { | ||
edges.push(link); | ||
} | ||
|
||
for (const links of Object.values(oneToManyRelations)) { | ||
for (const link of links) { | ||
edges.push(link); | ||
} | ||
} | ||
|
||
return { | ||
x: object.x, | ||
y: object.y, | ||
width: object.width, | ||
height: object.height, | ||
edges, | ||
}; | ||
} | ||
|
||
export function placeObjects(objects) { | ||
const nodes = []; | ||
const edges = []; | ||
|
||
const datatypes = objects.datatypes; | ||
const associations = objects.associations; | ||
|
||
for (const { collection, oneToOne, oneToMany } of Object.values(datatypes)) { | ||
for (const object of collection) { | ||
nodes.push(objectToNode(object)); | ||
} | ||
for (const links of Object.values(oneToOne)) { | ||
for (const link of links) { | ||
edges.push(link); | ||
} | ||
} | ||
for (const links of Object.values(oneToMany)) { | ||
for (const link of links) { | ||
edges.push(link); | ||
} | ||
} | ||
} | ||
|
||
for (const collection of Object.values(associations)) { | ||
for (const association of collection) { | ||
edges.push(association); | ||
} | ||
} | ||
|
||
console.log(nodes, edges); | ||
|
||
fruchtermanReingold(nodes, edges); | ||
} |
Oops, something went wrong.