Skip to content

Commit

Permalink
Remove parent-child links from auxiliary graph on layout (updates #9)
Browse files Browse the repository at this point in the history
In our trick with compound graphs layout links between parent and child
is reassigned to some child - child link which will only confuse the layout algorithm.
Therefore, such links should be removed from aux graph.
  • Loading branch information
Alexey Terentjev authored and Alexey Terentjev committed May 11, 2017
1 parent 976979a commit 6cab17c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/visual/Visualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,22 @@ function createSubstituteCells(graph) {
const newCells = [];
let cellIdx = 0;
_.forEach(newCellsMap, (newCell, key) => {
newCells[cellIdx] = newCell;
cellIdx += 1;
const cellProto = graph.getCell(key);
newCell.proto = cellProto;
if (newCell.isLink()) {
const source = newCellsMap[getHighestDescendant(cellProto.getSourceElement()).id];
const target = newCellsMap[getHighestDescendant(cellProto.getTargetElement()).id];
const protoSrc = cellProto.getSourceElement();
const protoDst = cellProto.getTargetElement();
if (protoDst.isEmbeddedIn(protoSrc, { deep: true }) ||
protoSrc.isEmbeddedIn(protoDst, { deep: true })) {
return;
}
const source = newCellsMap[getHighestDescendant(protoSrc).id];
const target = newCellsMap[getHighestDescendant(protoDst).id];
newCell.get('source').id = source.id;
newCell.get('target').id = target.id;
}
newCells[cellIdx] = newCell;
cellIdx += 1;
newCell.proto = cellProto;
});

const gr = new joint.dia.Graph();
Expand Down

0 comments on commit 6cab17c

Please sign in to comment.