문제

Is there any way by which I can specify minimum distance between nodes/edges in force directed graph?

I have some graphs in which one node is connected to hundreds of other nodes directly and in such cases it is really difficult to select a specific edge or node since edges and nodes are so close that onMouseEnter , onClick etc. events are not fired the way user expects it to be.

e.g. If nodeA and nodeB are really close, when I hover the nodeA and expect it to get highlighted , the nodeB is highlighted since event is fired for nodeB. Same is the case for edges when they are too close to each other. Basically it really gets confusing for the user to know which node/edge exactly is being hovered or selected.

I know we can specify the edge length. That can solve this problem to some extent but it does not help when you have hundreds of nodes and edges. And I can not set the edge length more than the height of canvas.

It would be very useful if we can specify some minimum distance between nodes/edges.

Does anyone know how can it be done?

도움이 되었습니까?

해결책

As the InfoVis/TheJit API Documentation, there's the .eachNode() function that allows you to loop through all nodes and retrieve their data.

$jit.Graph.Util.eachNode( graph, function( node ) {  
   console.log( node );
} );  
// or:
graph.eachNode( function( node ) {  
    console.log( node );
} );

As I haven't worked with InfoVis/TheJit for over a year and currently have no project set up, I don't know if you can retrieve the position with Graph.Node.getPos(). Anyway, if you figured this step out, you'd have to write an object/array/matrix that will hold the position. In case some el is to close to another el, you'd use Graph.Node.setPos() to relocate it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top