Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="paper-container"></div>
<a target="_blank" href="https://www.jointjs.com">
  <img id="logo" src="https://assets.codepen.io/7589991/jj-logo-red.svg" width="200" height="50"></img>
</a>
              
            
!

CSS

              
                #paper-container {
  position: absolute;
  right: 0;
  top: 0;
  left: 0;
  bottom: 0;
}

#logo {
  position: absolute;
  bottom: 20px;
  right: 0;
}


              
            
!

JS

              
                const { dia, shapes } = joint;

// Paper

const paperContainer = document.getElementById("paper-container");

const graph = new dia.Graph({}, { cellNamespace: shapes });
const paper = new dia.Paper({
  model: graph,
  cellViewNamespace: shapes,
  width: "100%",
  height: "100%",

  defaultConnectionPoint: {
    name: "boundary",
    args: {
      selector: false
    }
  },
  defaultLink: (elementView) => {
    return new joint.shapes.standard.Link({});
  },
  cellViewNamespace: joint.shapes,
  gridSize: 10,
  async: true,
  sorting: joint.dia.Paper.sorting.APPROX,
  linkPinning: false,
  snapLinks: true
});

paperContainer.appendChild(paper.el);

// Example

// Three rectangles wrapped in a group
// <g><rect/><rect/><rect/></g>
const el1 = new joint.shapes.uml.Class({
    position: {
        x: 10,
        y: 70
    },
    size: {
        width: 100,
        height: 90
    }
});

const el2 = el1.clone().position(250, 30);
const el3 = el1.clone().position(250, 130);


// <g @see="target points to this group"><rect/><rect/><rect/></g>
const link1 = new joint.shapes.standard.Link({
    source: { id: el1.id },
    target: { id: el2.id, connectionPoint: { name: 'boundary', args: { extrapolate: true, selector: false }}},
    labels: [{ attrs: { text: { text: 'lookup\ndisabled', fontFamily: 'sans-serif' }}}]
});

// <g><rect @see="target points to this group" /><rect/><rect/></g>
const link2 = new joint.shapes.standard.Link({
    source: { id: el1.id },
    target: { id: el3.id, connectionPoint: { name: 'boundary', args: { extrapolate: true }}},
    labels: [{ attrs: { text: { text: 'default\nlookup', fontFamily: 'sans-serif' }}}]
});
graph.resetCells([el1, el2, el3, link1, link2]);

paper.unfreeze();


              
            
!
999px

Console