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,
drawGrid: true,
async: true,
sorting: joint.dia.Paper.sorting.APPROX,
background: {
color: "#fff"
},
interactive: true,
});
///////////////////////////////////////////////////
// //
///////////////////_our example_///////////////////
// //
///////////////////////////////////////////////////
// this is how we get the svg from the backend
// this svg contains information about arrowlink display and content: information about markers
// for target and source
// You can view it in any online svg file viewer
// Specifically in this case we have information about the targetMarker(toPort) view
// and no information about the sourceMarker(fromPort) view
// because we only need the targetMarker in this case.
const customSVG = `
<svg id='main' width='70' height='20' version='1.1' xmlns='http://www.w3.org/2000/svg'>
<style>
polyline.common {
fill: blue;
stroke-width: 1;
stroke: black;
orient: auto;
}
path.common {
fill: blue;
stroke: black;
stroke-width: 1;
}
</style>
<defs>
<marker id='toPort' refX='5' refY='10' markerUnits='strokeWidth' markerWidth='21' markerHeight='20'>
<polyline id='toPolyline' class='common' points='0,0 20,10 0,20 5,10 0,0' />
</marker>
<marker id='fromPort' />
</defs>
<path class='common' d='M0 10 L50 10' style='marker-start: url(#fromPort); marker-end: url(#toPort);' />
</svg>
`;
// this is how we create our instance of the link
// as sourceMarker and targetMarker we want to pass our SVG element,
// but we want Joint itself to find the appropriate marker for sourceMarker and substitute it,
//...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.