JavaScript
var graph = new joint.dia.Graph({}, {
cellNamespace: joint.shapes
});
const paper = new joint.dia.Paper({
el: document.getElementById('paper'),
width: 1000,
height: 1000,
model: graph,
gridSize: 5,
drawGrid: true,
restrictTranslate: true,
cellViewNamespace: joint.shapes,
autoResizePaper: false,
defaultConnectionPoint: { name: 'boundary' },
defaultLink: new joint.shapes.standard.Link({
attrs: {
line: {
stroke: 'grey',
targetMarker: {
type: 'path',
d: 'M 0 0 0 0',
},
},
},
}),
interactive: { linkMove: true },
async: true,
snapLabels: true,
sorting: joint.dia.Paper.sorting.APPROX,
defaultLinkAnchor: { name: 'connectionPerpendicular' },
validateConnection:()=>{return true;}
});
let json=JSON.parse('{"cells":[{"type":"standard.Link","source":{"x":330,"y":391.1064147949219},"target":{"x":610,"y":391.1064147949219},"router":{"name":"normal"},"id":"176ec716-0a1d-47ac-8446-0a92afbeee83","z":1,"hoverPostion":{"x":103,"y":279},"vertices":[],"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}},{"type":"standard.Link","source":{"x":665,"y":205},"target":{"x":665,"y":565},"router":{"name":"normal"},"id":"84f20eb9-b075-4b6c-b827-7f3c633dca16","z":2,"hoverPostion":{"x":588,"y":288},"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}},{"type":"standard.Link","source":{"x":270,"y":215},"target":{"x":270,"y":575},"router":{"name":"normal"},"id":"60ff0366-c276-4667-a5be-e00688d4c5f5","z":3,"hoverPostion":{"x":173,"y":195},"attrs":{"line":{"stroke":"#808080","targetMarker":{"d":"M 0 0 0 0","stroke":"none"},"sourceMarker":{"stroke":"none"}}}}]}');
// Example
graph.fromJSON(json);
// Example
paper.on('link:connect', function(linkView, evt,...