anvaka / VivaGraphJS

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

Center Vivagraph wrapping div on node #114

Closed MarioVillani closed 9 years ago

MarioVillani commented 9 years ago

Hi, i'm showing a Vivagraph graph in a Bootstrap modal. This is my markup

<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
            ×
        </button>
        <h4 class="modal-title">Info</h4>
    </div>
    <div class="modal-body"><div id="graph1"></div></div>
    <div class="modal-footer">
        <button data-dismiss="modal" class="button" type="button">Cancel</button>
        <button type="button" class="button">Ok</button>
    </div>
</div>

Graph 1 CSS:

#graph1 {
    height: 600px;
    width: 562px;
}

When graph is painted, i would like center the viewing area on a certain node painted. Actually i need to click and drag in the modal body to view the graph correctly. Is there a way to fix this? How can i center the current view on a node?Thanks.

anvaka commented 9 years ago

Hi Mario.

Would this work?

var pos = layout.getNodePosition(nodeId);
renderer.moveTo(pos.x, pos.y);
anvaka commented 9 years ago

Resolving this.