Search code examples
javascriptvis.jsvis.js-network

Vis.js fixed node rendering incorrectly in large graph at large scale


I am trying to render a graph in vis.js that has 64 nodes with edges between each. Each of the 64 nodes is also connected to one of 8 additional nodes. I want the 8 additional nodes to be fixed in an octagon shape around the outside of the mass of 64x64 node/edges. Thus, they are the vertices of the octagon. Since this is a large graph with a lot of edges I am rendering at large scale, fixing the octagon vertices at 20000 units from the center (in vis.js network coordinate system).

Beyond a small number of nodes/edges, the octagon vertices do not stay fixed even though I am setting node options in vis.js as follows (for example of one of the 8):

{
  fixed: true,
  physics: false,
  x: 20000,
  y: 0
}

Here is a jsbin that shows that point beyond which the fixed node functionality breaks: http://jsbin.com/mewaguxibe/1/edit?html,output

Any thoughts on how to fix this? Or is it a bug?


Solution

  • I think it's vis.js internal error or misbehavior.

    After I explicitly set node 8 and node 9 x and y to 0

    It works correctly!

    Maybe it's because of internal calculation in vis when you didn't set position of node.

    {
        "id": 8,
        "x": 0,
        "y": 0,
    },
    {
        "id": 9,
        "x": 0,
        "y": 0,
    }
    

    JSBin