Custom link #1677
-
Hi there, Here is my code.
When I draw element and link using port, it draw like below picture. And I want to remove arrows and black circles in the middle. I saw the tutorial link below, but it only explain change link manually. But I need to change the link from port. Which mean setting the link and create it when I use port. Thank you all |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi, when drawing a link from an active magnet/port, the default link is It is possible to change the default link using the You could change it to new joint.dia.Paper({
el: document.getElementById('paper'),
model: graph,
width: 1500,
drawGrid: true,
defaultLink: () => new joint.shapes.standard.Link(),
}); If you create a custom link yourself, you can also provide it here as the We will update our ports documentation and tutorials to make this more clear. Thanks, James |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, it seems like maybe, you want to use some linkTools after all, but just edit how they look if I understand correctly. It is possible to add a You can take advantage of events to add or remove the linkTools: // Register events
paper.on('link:mouseenter', (linkView) => {
showLinkTools(linkView);
});
paper.on('link:mouseleave', (linkView) => {
linkView.removeTools();
});
// Actions
function showLinkTools(linkView) {
const tools = new joint.dia.ToolsView({
tools: [
new joint.linkTools.Remove({
distance: '50%',
markup: [{
tagName: 'circle',
selector: 'button',
attributes: {
'r': 7,
'fill': '#f6f6f6',
'stroke': '#ff5148',
'stroke-width': 2,
'cursor': 'pointer'
}
}, {
tagName: 'path',
selector: 'icon',
attributes: {
'd': 'M -3 -3 3 3 M -3 3 3 -3',
'fill': 'none',
'stroke': '#ff5148',
'stroke-width': 2,
'pointer-events': 'none'
}
}]
}),
new joint.linkTools.SourceArrowhead(),
new joint.linkTools.TargetArrowhead()
]
});
linkView.addTools(tools);
} You could then style the <style>
path.target-arrowhead {
d: path('M -10 -5 0 0 -10 5 Z');
cursor: move;
stroke: black;
stroke-width: 1;
fill: black;
}
path.source-arrowhead {
d: path('M 10 -5 0 0 10 5 Z');
cursor: move;
stroke: black;
stroke-width: 1;
fill: black;
}
</style> Of course, you can edit the attributes and styles to get your desired look. Thanks, James |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hi,
it seems like maybe, you want to use some linkTools after all, but just edit how they look if I understand correctly.
https://resources.jointjs.com/docs/jointjs/v3.5/joint.html#linkTools
It is possible to add a
Remove
button via linkTools for example. You can also addSourceArrowhead
andTargetArrowhead
which allow you to change target and source.You can take advantage of events to add or remove the linkTools:
https://resources.jointjs.com/docs/jointjs/v3.5/joint.html#dia.Paper.events