How To Import Json Data In D3?
How do I import json file in D3? I did d3.json('temp.json'); But how do I access this data set in further code? So far I have tried: var data=d3.json('temp.json'); But using .dat
Solution 1:
The function d3.json()
is asynchronous. Thus, you have to wait for the data to be received before reading the data
variable. This is the reason why, when dealing with asynchronous data, the practice is to do everything inside the d3.json()
function
d3.json("temp.json", function(error, data){
//use data here
})
// do not use data anymore
Post a Comment for "How To Import Json Data In D3?"