From 24c62f51f73a5567f7932d819ee21ccd1c10b1a0 Mon Sep 17 00:00:00 2001 From: Yanyan-Wang Date: Wed, 1 Apr 2020 22:15:10 +0800 Subject: [PATCH] feat: render zindex for combos when first render and changeData --- src/graph/graph.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/graph/graph.ts b/src/graph/graph.ts index 6da6b5529c..7f4e22f572 100644 --- a/src/graph/graph.ts +++ b/src/graph/graph.ts @@ -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 数据