How do I load JSON data synchronously with d3.js?

后端 未结 2 944
故里飘歌
故里飘歌 2020-12-09 19:59

When my site first initializes, it queries a server to get back some data. I can\'t lay anything out on the page until this data gets back. With d3.js, I can use d3.json()

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 20:36

    You're basically doing it the only way. The callback function has to be the one initiating the rest of your code. You don't need all your code in the callback function though, you can introduce indirection. So the callback function will call another function inside which would be what is currently in your callback function.

提交回复
热议问题