mirror of
https://gitee.com/antv/g6.git
synced 2024-12-04 04:38:55 +08:00
feat: render zindex for combos when first render and changeData
This commit is contained in:
parent
4ee18ceeae
commit
3798b476c2
@ -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 数据
|
||||
|
@ -249,7 +249,6 @@ const DefaultCombo = () => {
|
||||
//graph.focusItem(graph.getCombos()[0]);
|
||||
// graph.remove('B');
|
||||
// graph.remove('A');
|
||||
|
||||
// graph.changeData(data2);
|
||||
// graph.changeData(graph.save());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user