2021-07-31 16:43:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
SV.registerLayouter('Stack', {
|
|
|
|
|
|
|
|
sourcesPreprocess(sources, options) {
|
|
|
|
const stackBottomNode = sources[sources.length - 1];
|
|
|
|
|
|
|
|
if(stackBottomNode.external) {
|
|
|
|
stackBottomNode.bottomExternal = stackBottomNode.external;
|
|
|
|
delete stackBottomNode.external;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(options.layout.indexPosition) {
|
|
|
|
sources.forEach(item => {
|
|
|
|
item.indexPosition = options.layout.indexPosition;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return sources;
|
|
|
|
},
|
|
|
|
|
|
|
|
defineOptions() {
|
|
|
|
return {
|
|
|
|
element: {
|
|
|
|
default: {
|
|
|
|
type: 'indexed-node',
|
|
|
|
label: '[id]',
|
|
|
|
size: [60, 30],
|
|
|
|
style: {
|
|
|
|
stroke: '#333',
|
|
|
|
fill: '#95e1d3'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-08-17 15:44:28 +00:00
|
|
|
marker: {
|
2021-07-31 16:43:01 +00:00
|
|
|
external: {
|
2021-08-17 15:44:28 +00:00
|
|
|
type: 'pointer',
|
2021-07-31 16:43:01 +00:00
|
|
|
anchor: 1,
|
|
|
|
style: {
|
|
|
|
fill: '#f08a5d'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
bottomExternal: {
|
2021-08-17 15:44:28 +00:00
|
|
|
type: 'pointer',
|
2021-07-31 16:43:01 +00:00
|
|
|
anchor: 2,
|
|
|
|
style: {
|
|
|
|
fill: '#f08a5d'
|
|
|
|
}
|
2021-08-17 15:44:28 +00:00
|
|
|
},
|
|
|
|
cursor: {
|
|
|
|
type: 'cursor',
|
|
|
|
anchor: 1,
|
|
|
|
style: {
|
|
|
|
fill: '#f08a5d'
|
|
|
|
}
|
2021-07-31 16:43:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
layout: {
|
|
|
|
indexPosition: 'left'
|
|
|
|
},
|
|
|
|
behavior: {
|
|
|
|
dragNode: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
layout(elements, layoutOptions) {
|
|
|
|
let blocks = elements;
|
|
|
|
|
|
|
|
for(let i = 1; i < blocks.length; i++) {
|
|
|
|
let item = blocks[i],
|
|
|
|
prev = blocks[i - 1],
|
|
|
|
height = item.get('size')[1];
|
|
|
|
|
|
|
|
item.set('y', prev.get('y') + height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|