However, I wouldn't recommend it; it blocks the entire browser until
the request completes. It'd be much better—for example—to make the
select menu disabled while the required file is loading, and then
undisable it when the file loads. That way, you prevent the user from
entering a conflicting state, but you don't lock up the entire browser
and you allow limited interaction.
Also, you may want to disable a "loading" state while you are loading files.
One feature I would like to add is a way to cancel outstanding
requests. I think it'd be pretty easy to return an object from d3.xhr
(and friends) that has an abort() method.
Mike
It's not so much the hang while a working load works, it's the very
very long hang when a load *fails* for some reason.
If you're going to be in a "just don't worry about the warts" mode,
it's probably still better to be async with an
temporarily-inconsistent UI.
-n
Mike
var data1, data2, data3;
d3.csv('path/file1.csv', function(data) {...manipulate my data in to data1 variable...})
readyCheck('file1');
d3.csv('path/file2.csv', function(data) {...manipulate my data in to data2 variable...})
readyCheck('file2');
d3.csv('path/file3.csv', function(data) {...manipulate my data in to data3 variable...})
readyCheck('file3');
var readyFiles = {'file1': false, 'file2': false, 'file3': false};
function readyCheck(filename) {readyFiles[filename] = true;}
if (readyFiles['file1']==true && readyFiles['file2']==true && readyFiles['file3']==true) {...begin drawing visualization...}