Is there any way to make d3.csv() be synchronous instead of asynchronous?
My code is getting to be a mess with callbacks since I load multiple csv files according to different triggers on the page.
d3.csv is asynchronous by design to prevent pages from freezing up, so that can't be changed without changing the d3 library itself.
However, you could pre-load all your files via d3.text() and call d3.csv.parse or d3.csv.parseRows, which will be synchronous given that the text file has been loaded.
For an example, see Mike Bostock's answer in this post this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With