feat: 增加根据选中节点功能
This commit is contained in:
parent
e155269533
commit
9f98b0abde
@ -106,7 +106,20 @@ SV.registerLayouter('GeneralizedList', {
|
|||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
loopSub: {},
|
loopSub: {},
|
||||||
loopNext: {},
|
loopNext: {
|
||||||
|
type: 'quadratic',
|
||||||
|
curveOffset: -50,
|
||||||
|
sourceAnchor: 2,
|
||||||
|
targetAnchor: 4,
|
||||||
|
style: {
|
||||||
|
stroke: '#333',
|
||||||
|
endArrow: 'default',
|
||||||
|
startArrow: {
|
||||||
|
path: G6.Arrow.circle(2, -1),
|
||||||
|
fill: '#333'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
sub: {
|
sub: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
sourceAnchor: 2,
|
sourceAnchor: 2,
|
||||||
|
|||||||
@ -90,20 +90,44 @@
|
|||||||
|
|
||||||
|
|
||||||
let data = [{
|
let data = [{
|
||||||
"g1": {
|
GeneralizedList: {
|
||||||
"data": [
|
data: [
|
||||||
{ id: 0, neighbor: [4, 3] }, { id: 1, neighbor: [0, 3] }, { id: 2, neighbor: [4, 0] },
|
{
|
||||||
{ id: 3, neighbor: [5, 2] }, { id: 4 },
|
"type": "table",
|
||||||
{ id: 5, neighbor: [0, 1] }
|
"id": 1000,
|
||||||
|
"next": "table#1001",
|
||||||
|
"tag": 1,
|
||||||
|
"sub": "atom#1002",
|
||||||
|
root: true,
|
||||||
|
"external": [
|
||||||
|
"gl"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "table",
|
||||||
|
"id": 1001,
|
||||||
|
"tag": 1,
|
||||||
|
"external": [
|
||||||
|
"gl1"
|
||||||
],
|
],
|
||||||
// "layouter": "AdjoinTableGraph"
|
loopNext: 'table#1000'
|
||||||
"layouter": "AdjoinMatrixGraph"
|
},
|
||||||
|
{
|
||||||
|
"type": "atom",
|
||||||
|
"id": 1002,
|
||||||
|
"tag": 0,
|
||||||
|
"data": "e",
|
||||||
|
"external": [
|
||||||
|
"p4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
layouter: "GeneralizedList"
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let dataIndex = 0,
|
let dataIndex = 0,
|
||||||
curData = data[dataIndex];
|
curData = data[dataIndex];
|
||||||
|
|
||||||
@ -125,12 +149,6 @@
|
|||||||
cur.render(curData);
|
cur.render(curData);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cur.on('onLeak', () => { });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const container = document.getElementById('container'),
|
const container = document.getElementById('container'),
|
||||||
pos = document.getElementById('pos');
|
pos = document.getElementById('pos');
|
||||||
|
|
||||||
@ -140,7 +158,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById('hide').addEventListener('click', () => {
|
||||||
|
cur.selectElement(1000, ele => {
|
||||||
|
ele.set('label', '6666');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -268,7 +268,6 @@ export class ModelConstructor {
|
|||||||
element.sourceElement = sourceElement;
|
element.sourceElement = sourceElement;
|
||||||
// 处理element的index文本
|
// 处理element的index文本
|
||||||
this.resolveElementIndex(element.get('indexCfg'), sourceElement);
|
this.resolveElementIndex(element.get('indexCfg'), sourceElement);
|
||||||
console.log(element.get('indexCfg'));
|
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -199,6 +199,21 @@ export class Engine {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用id选中某个节点
|
||||||
|
* @param id
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
public selectElement(id: string, callback?: (element: Element) => void) {
|
||||||
|
const elements = this.getElements();
|
||||||
|
const stringId = id.toString();
|
||||||
|
const targetElement = elements.find(item => item.sourceId === stringId);
|
||||||
|
|
||||||
|
if(targetElement) {
|
||||||
|
callback && callback(targetElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整容器尺寸
|
* 调整容器尺寸
|
||||||
* @param containerName
|
* @param containerName
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user