JavaScript
var portsIn = {
position: {
name: 'left'
},
attrs: {
portBody: {
fill: '#023047',
stroke: '#023047'
}
},
label: {
position: {
name: 'left',
args: {
y: 0,
x: 16
},
},
markup: [{
tagName: 'text',
selector: 'label',
className: 'label-text'
}]
},
markup: [{
tagName: 'rect',
selector: 'portBody',
width: 25,
attributes: {
'fill': 'transparent'
}
}]
};
var portsOut = {
position: {
name: 'right'
},
attrs: {
portBody: {
fill: '#E6A502',
stroke: '#023047'
}
},
label: {
position: {
name: 'right',
args: {
y: 0,
x: -15
}
},
markup: [{
tagName: 'text',
selector: 'label',
className: 'label-text'
}]
},
markup: [{
tagName: 'rect',
selector: 'portBody',
width: 25,
attributes: {
'fill': 'transparent'
}
}]
};
var componentList = [
{
componentName: "A",
incomingPort: ["11", "12", "13"],
outgoingPort: [{
srcPort: "1A",
destPort: "21",
destElem: "B"
},
{
srcPort: "1B",
destPort: "22",
destElem: "B"
},
{
srcPort: "1C",
destPort: "31",
destElem: "C"
},
],
position: {
x: 50,
y: 150
},
},
{
componentName: "B",
incomingPort: ["21", "22", "23"],
outgoingPort: [],
position: {
x: 300,
y: 100
},
},
{
componentName: "C",
incomingPort: ["31", "32", "33"],
outgoingPort: [],
position: {
x: 300,
y: 200
},
}
];
var graph = new joint.dia.Graph({}, {
cellNamespace: joint.shapes
});
const paper = new joint.dia.Paper({
el: document.getElementById('paper'),
width: 800,
height: 900,
model: graph,
defaultConnectionPoint: {
name: 'boundary'
},
cellViewNamespace: joint.shapes,
gridSize: 10,
async: true,
...