Here is a JSON object:
{
"temp_data": [10,15,20]
}
I'm trying to import it:
var temp_data;
//Importing from JSON
if(true){
d3.json("graph.json", function(error, graph) {
if (error){
throw error;
}
temp_data = graph.temp_data;
console.log(temp_data); //successfully logs data
});
}
console.log("temp: " + temp_data); //Cannot retrieve data
The issue is that even though temp_data is declared as a global variable, the second log does not display the data.