Fixed a small positioning issue with dagre demo

The dagre example doesn't take into account that dagre works with center of position for nodes but react-diagrams works with top left of position for nodes.

To correctly position the nodes, half of the width and height should be subtracted from the x and y axis respectively.
This commit is contained in:
JoasE
2018-11-30 14:12:24 +01:00
committed by GitHub
parent e3fc996092
commit 591ec2e76e

View File

@@ -11,8 +11,8 @@ export function distributeElements(model) {
let nodes = distributeGraph(clonedModel);
nodes.forEach(node => {
let modelNode = clonedModel.nodes.find(item => item.id === node.id);
modelNode.x = node.x;
modelNode.y = node.y;
modelNode.x = node.x - (node.width / 2);
modelNode.y = node.y - (node.height / 2);
});
return clonedModel;
}