i am working around a cola.js example enter link description here
and i added markers (arrows) a the end of the links. However, since the nodes are rectangular are overlaping the arrows. I tried to fix it by changing 'refX' of marker but is not looking good.
The code of the marker is :
// define arrow markers for graph links
svg.append('svg:defs').append('svg:marker')
.attr('id', 'end-arrow')
.attr('viewBox', '0 -5 10 10')
.attr('refX', 30)
//.attr("refY", -1.5)
.attr('markerWidth', 6)
.attr('markerHeight', 6)
.attr('orient', 'auto')
.append('svg:path')
.attr('d', 'M0,-5L10,0L0,5')
.attr('fill', '#000');
and then add it in the end of link:
` cola.on("tick", function () {
link.attr("x1", function (d) { return d.source.x; })
.attr("y1", function (d) { return d.source.y; })
.attr("x2", function (d) { return d.target.x; })
.attr("y2", function (d) { return d.target.y; })
.attr("marker-end","url(#end-arrow)");
`
If i may recommend another way to create your edges.
Following this example here - disclaimer it seems the actual example is broken due to what im assuming is a typo in the code.
long story short. the important part is this inside your cola.on("tick" function(){
the third argument (5) for makeEdgeBetween, if i'm not mistaken, is spacing to take into account your arrowhead length, if you look at the source it should be called ah. And im pretty sure the makeEdgeBetween function will create the edge up until the rectangular boundary of the node, instead of the centre