Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3: make the d3.csv function syncronous

Tags:

d3.js

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.

like image 647
Don P Avatar asked Nov 11 '13 04:11

Don P


1 Answers

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.

like image 108
THK Avatar answered Oct 07 '22 22:10

THK