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 4ee18ceeae
commit 3798b476c2
2 changed files with 30 additions and 1 deletions

View File

@ -1912,6 +1912,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

View File

@ -249,7 +249,6 @@ const DefaultCombo = () => {
//graph.focusItem(graph.getCombos()[0]);
// graph.remove('B');
// graph.remove('A');
// graph.changeData(data2);
// graph.changeData(graph.save());