Search code examples
javascriptnode.jspromisevis.js

Vis.js callback when the network finishes loading


I'm using a vis.js network that takes in some data and add's said data as nodes within the network.

The only issue is that after the network has been declared (using the nodes and edges specified, which may be a lot) it takes a while for the nodes in the network to render in.

Even when I declare the network like so:

var network = new vis.Network(container, data, options);

And then follow it up with making the container visible:

$('#BreakdownBox').css('display','inline');

It still becomes visible before the nodes have finished buffering, showing a blank canvas until they've rendered in.

My Question: How can I only make it visible once it's finished loading the nodes? Is there a way to use the promises.js with this? Something like:

var network = new vis.Network(container, data, options).done(function{
    $('#BreakdownBox').css('display','inline');
});

Solution

  • In the end I used the native loading bar to vis.js, using their example code here

    It's a little faulty but it's all I needed.