feat: layout for combo. feat: nonoverlap for combo layout in first stage.

This commit is contained in:
Yanyan-Wang 2020-04-07 20:21:07 +08:00 committed by Yanyan Wang
parent d1feaea737
commit 9d1ff111d0
4 changed files with 2 additions and 10 deletions

View File

@ -1220,13 +1220,10 @@ export default class Graph extends EventEmitter implements IGraph {
const self = this;
const comboTrees = this.get('comboTrees');
const itemController: ItemController = self.get('itemController');
const itemMap = self.get('itemMap');
comboTrees && comboTrees.forEach((ctree: ComboTree) => {
traverseTreeUp<ComboTree>(ctree, child => {
if (!child) {
return false
}
const childItem = itemMap[child.id];
if (childItem && childItem.getType() === 'combo') {
itemController.updateCombo(childItem, child.children);

View File

@ -385,7 +385,6 @@ export default class ComboForce extends BaseLayout {
});
c.cx /= c.count;
c.cy /= c.count;
return true;
});
});
@ -430,7 +429,6 @@ export default class ComboForce extends BaseLayout {
const childIdx = nodeIdxMap[node.id];
displacements[childIdx].x -= vecX * comboGravity * alpha / l * gravityScale;
displacements[childIdx].y -= vecY * comboGravity * alpha / l * gravityScale;
if (isNumber(node.x)) {
c.cx += node.x;
}
@ -440,7 +438,6 @@ export default class ComboForce extends BaseLayout {
});
c.cx /= c.count;
c.cy /= c.count;
return true;
});
});
@ -611,7 +608,6 @@ export default class ComboForce extends BaseLayout {
if (!isNumber(v.x) || !isNumber(u.x) || !isNumber(v.y) || !isNumber(u.y)) return;
let { vl, vx, vy } = vecMap[`${v.id}-${u.id}`];
if (vl > max) return;
const depthDiff = Math.abs(u.depth - v.depth);
let depthParam = depthDiff ? Math.pow(scale, depthDiff) : 1;
if (u.comboId !== v.comboId && depthParam === 1) {
@ -672,7 +668,6 @@ export default class ComboForce extends BaseLayout {
const vecX = vx * l;
const vecY = vy * l;
const b = bias[i];
const depthDiff = Math.abs(u.depth - v.depth);
let depthParam = depthDiff ? Math.pow(scale, depthDiff) : 1;
if (u.comboId !== v.comboId && depthParam === 1) {

View File

@ -501,6 +501,7 @@ export const plainCombosToTrees = (array: ComboConfig[], nodes?: INode[]) => {
addedMap[nodeModel.id] = cnode;
}
});
result.forEach((tree: ComboTree) => {
tree.depth = 0;
traverse<ComboTree>(tree, child => {

View File

@ -519,7 +519,6 @@ const G6ForceLayout = () => {
color: '#666',
}
});
graph.node(node => {
const color = colors[node.comboId as string];
return {