feat: render zindex for combos when first render and changeData

This commit is contained in:
Yanyan-Wang 2020-04-01 22:15:10 +08:00 committed by Yanyan Wang
parent ec87457eb2
commit 24c62f51f7

View File

@ -1909,6 +1909,36 @@ export default class Graph extends EventEmitter implements IGraph {
}
}
private sortCombos(data: GraphData) {
const depthMap = [];
const dataDepthMap = {};
const comboTrees = this.get('comboTrees');
comboTrees.forEach(cTree => {
traverseTree(cTree, child => {
if (depthMap[child.depth]) depthMap[child.depth].push(child.id);
else depthMap[child.depth] = [ child.id ];
dataDepthMap[child.id] = child.depth;
return true;
});
});
data.edges.forEach(edge => {
const sourceDepth: number = dataDepthMap[edge.source] || 0;
const targetDepth: number = dataDepthMap[edge.target] || 0;
const depth = Math.max(sourceDepth, targetDepth);
console.log(depth, edge.id, edge.source, edge.target, sourceDepth, targetDepth);
if (depthMap[depth]) depthMap[depth].push(edge.id);
else depthMap[depth] = [ edge.id ];
});
console.log(depthMap);
depthMap.forEach(array => {
if (!array || !array.length) return;
for (let i = array.length - 1; i >= 0; i--) {
const item = this.findById(array[i]);
item.toFront();
}
});
}
/**
* comboTree Combo Combo
* @param {GraphData} data