Here is a snippet of my code:
var cdata = [];
d3.text("tests.info", function(text) {
var data = d3.csv.parseRows(text);
data.forEach(function(d) {
cdata.push({key: d[0], values: []});
});
});
The code reads a CSV file, loops through each line, and adds them into an array. I have confirmed that the data is being added correctly.
However, the problem arises when trying to access the array later on - it appears empty as if no data was ever added (even though I know this isn't the case).
I suspect it could be related to scoping, although I initially thought that push()
should work in this context regardless.