feat: 增加根据选中节点功能
This commit is contained in:
parent
e155269533
commit
9f98b0abde
@ -106,7 +106,20 @@ SV.registerLayouter('GeneralizedList', {
|
||||
},
|
||||
link: {
|
||||
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: {
|
||||
type: 'line',
|
||||
sourceAnchor: 2,
|
||||
|
||||
@ -90,18 +90,42 @@
|
||||
|
||||
|
||||
let data = [{
|
||||
"g1": {
|
||||
"data": [
|
||||
{ id: 0, neighbor: [4, 3] }, { id: 1, neighbor: [0, 3] }, { id: 2, neighbor: [4, 0] },
|
||||
{ id: 3, neighbor: [5, 2] }, { id: 4 },
|
||||
{ id: 5, neighbor: [0, 1] }
|
||||
GeneralizedList: {
|
||||
data: [
|
||||
{
|
||||
"type": "table",
|
||||
"id": 1000,
|
||||
"next": "table#1001",
|
||||
"tag": 1,
|
||||
"sub": "atom#1002",
|
||||
root: true,
|
||||
"external": [
|
||||
"gl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "table",
|
||||
"id": 1001,
|
||||
"tag": 1,
|
||||
"external": [
|
||||
"gl1"
|
||||
],
|
||||
loopNext: 'table#1000'
|
||||
},
|
||||
{
|
||||
"type": "atom",
|
||||
"id": 1002,
|
||||
"tag": 0,
|
||||
"data": "e",
|
||||
"external": [
|
||||
"p4"
|
||||
]
|
||||
},
|
||||
],
|
||||
// "layouter": "AdjoinTableGraph"
|
||||
"layouter": "AdjoinMatrixGraph"
|
||||
layouter: "GeneralizedList"
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
let dataIndex = 0,
|
||||
@ -125,12 +149,6 @@
|
||||
cur.render(curData);
|
||||
});
|
||||
|
||||
|
||||
|
||||
cur.on('onLeak', () => { });
|
||||
|
||||
|
||||
|
||||
const container = document.getElementById('container'),
|
||||
pos = document.getElementById('pos');
|
||||
|
||||
@ -140,7 +158,11 @@
|
||||
});
|
||||
|
||||
|
||||
|
||||
document.getElementById('hide').addEventListener('click', () => {
|
||||
cur.selectElement(1000, ele => {
|
||||
ele.set('label', '6666');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</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的index文本
|
||||
this.resolveElementIndex(element.get('indexCfg'), sourceElement);
|
||||
console.log(element.get('indexCfg'));
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user