block by eesur cf81a5ea738f85732707

Pre-loading using spin.js with d3

Full Screen

Example using spin.js during load of JSON data for a D3 chart

Showing the spinner/loader being triggered before the JSON callback, and stopped within the JSON callback (hence after the JSON data has been loaded):

// loader settings
var target = document.getElementById('#chart-id');

function init() {

    // trigger loader
    var spinner = new Spinner(opts).spin(target);

    // load json data 
    data.loadJson(chartConfig.data_url, function(data) {

        // stop the loader
        spinner.stop();

        // code to execute within callback

    });
}

init();

index.html

external_data.json