mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
admin ui: fix data erd layout
This commit is contained in:
@@ -25,12 +25,6 @@ export const layoutWithDagre = ({ nodes, edges, graph }: LayoutProps) => {
|
|||||||
const dagreGraph = new Dagre.graphlib.Graph();
|
const dagreGraph = new Dagre.graphlib.Graph();
|
||||||
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
||||||
dagreGraph.setGraph(graph || {});
|
dagreGraph.setGraph(graph || {});
|
||||||
/*dagreGraph.setGraph({
|
|
||||||
rankdir: "LR",
|
|
||||||
align: "UR",
|
|
||||||
nodesep: NODE_SEP,
|
|
||||||
ranksep: RANK_SEP
|
|
||||||
});*/
|
|
||||||
|
|
||||||
nodes.forEach((node) => {
|
nodes.forEach((node) => {
|
||||||
dagreGraph.setNode(node.id, {
|
dagreGraph.setNode(node.id, {
|
||||||
@@ -48,7 +42,11 @@ export const layoutWithDagre = ({ nodes, edges, graph }: LayoutProps) => {
|
|||||||
return {
|
return {
|
||||||
nodes: nodes.map((node) => {
|
nodes: nodes.map((node) => {
|
||||||
const position = dagreGraph.node(node.id);
|
const position = dagreGraph.node(node.id);
|
||||||
return { ...node, x: position.x, y: position.y };
|
return {
|
||||||
|
...node,
|
||||||
|
x: position.x - (node.width ?? 0) / 2,
|
||||||
|
y: position.y - (node.height ?? 0) / 2
|
||||||
|
};
|
||||||
}),
|
}),
|
||||||
edges
|
edges
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,15 +69,13 @@ export function DataSchemaCanvas() {
|
|||||||
const nodeLayout = layoutWithDagre({
|
const nodeLayout = layoutWithDagre({
|
||||||
nodes: nodes.map((n) => ({
|
nodes: nodes.map((n) => ({
|
||||||
id: n.id,
|
id: n.id,
|
||||||
...EntityTableNode.getSize(n)
|
...EntityTableNode.getSize(n.data)
|
||||||
})),
|
})),
|
||||||
edges,
|
edges,
|
||||||
graph: {
|
graph: {
|
||||||
rankdir: "LR",
|
rankdir: "LR",
|
||||||
//align: "UR",
|
marginx: 50,
|
||||||
ranker: "network-simplex",
|
marginy: 50
|
||||||
nodesep: 350,
|
|
||||||
ranksep: 50
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,12 +86,6 @@ export function DataSchemaCanvas() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*const _edges = edges.map((e) => ({
|
|
||||||
...e,
|
|
||||||
source: e.source + `-${e.target}_id`,
|
|
||||||
target: e.target + "-id"
|
|
||||||
}));*/
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactFlowProvider>
|
<ReactFlowProvider>
|
||||||
<Canvas
|
<Canvas
|
||||||
|
|||||||
Reference in New Issue
Block a user