Reputation: 5409
I'm using d3Queue with a d3 Choropleth. When my data is in CSV format, it works fine:
CSV Data:
state, count
1, 100
2, 200
3, 300
and
.defer(d3.csv, data, function(d) {
rateById.set(d.state, +d.count);
})
However, now my data is in JSON format.
JSON Data:
[
{
state: 1,
count: 100
},
{
state: 2,
count: 200
}
]
And I changed my .defer
to this:
.defer(d3.json, data, function(d) {
rateById.set(d.state, +d.count);
})
But it is throwing the error: "Cannot read property 'state' of null". Does this mean the data is not being passed through, or that I'm messing up reading the JSON?
Upvotes: 0
Views: 187
Reputation: 2599
Reading over the queue.js API, it looks like this should work:
.defer(d3.json, data) // .defer(task, [arguments]);
.await(function(d) {
rateById.set(d.state, +d.count);
}); // .await(callback)
Upvotes: 1