Github Discussion #1801

https://github.com/clientIO/joint/discussions/1801

by Roman Bruckner

HTML

<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.5.5/joint.css" />
</head>
<body>
      <!-- content -->
      <div id="paper"></div>         

      <!-- dependencies -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.4.0/backbone.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.5.5/joint.js"></script>
    
    </body>
</html>

CSS

.joint-paper {
  display: inline-block;
  border: 1px solid gray;
}

JavaScript

const shapes = { ...joint.shapes };
var graph = new joint.dia.Graph({}, { cellNamespace: shapes });
var paper = new joint.dia.Paper({
    el: document.getElementById('paper'),
    width: 800,
    height: 600,
    model: graph,
    cellViewNamespace: shapes,
    defaultConnector: {
       name: 'curve'
    },
    defaultConnectionPoint: {
        name: 'boundary',
    },
    defaultAnchor: {
        name: 'midSide'
    }
});


const r1 = new joint.shapes.standard.Rectangle({
    position: { x: 100, y: 100 },
    size: { width: 100, height: 100 },
});

const r2 = new joint.shapes.standard.Rectangle({
    position: { x: 600, y: 100 },
    size: { width: 100, height: 100 },
});

const link = new joint.shapes.standard.Link({
    source: { id: r1.id },
    target: { id: r2.id }
});

graph.addCells([r1, r2, link]);

link.findView(paper).addTools(new joint.dia.ToolsView({
    tools: [
        new joint.linkTools.Vertices(),
    ]
}));