I am experiencing a strange behavior when I read csv file inside my script (my first attempt at reading CSV in D3). I am unable to access the data inside the script yet I am able to see it in the console. My CSV file as two columns of data with 'time" and 'pos_n' as headers. Here is my code:
var myData = []
d3.csv("my_sample.csv", function(data) {
myData = data.map(function(d){
return [+d["time"], +d["pos_n"]];
})});
console.log("from inside the code, length of myData: ", myData.length)
Here is the output from console: Output from console
Not sure how to make my code see myData array. Any pointers would be greatly appreciated.
Thanks!