anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.76k stars 425 forks source link

How to change link position #133

Closed richa2008 closed 9 years ago

richa2008 commented 9 years ago

Hi, I am working on vivagraph.I am assigning some predefined position to nodes and want the link also to reposition at that place.But the position of links is not changing.How to do that.Please help.Thanks.

anvaka commented 9 years ago

Graphics object provides two methods which allows you to modify link UI and its position:

 graphics.link(function(link){
    return Viva.Graph.svg('path')
                .attr('stroke', 'red')
                .attr('stroke-dasharray', '5, 5');
}).placeLink(function(linkUI, fromPos, toPos) {
    // You can assign position that you desire here:
    var data = 'M' + fromPos.x + ',' + fromPos.y +
                'L' + toPos.x + ',' + toPos.y;
    linkUI.attr("d", data);
});

Would this work?