Reading in data from a csv or json
There are a few ways to do it, but we’re always going to use a queue
.
// Read in these three files, then run the ready function
d3.queue()
.defer(d3.csv, "../car-data.csv")
.defer(d3.json, "map-data.json")
.defer(d3.csv, "dinosaur-information.csv")
.await(ready)
function ready(error, cars, map, dinosaurs) {
if(error) throw error;
// All of the car data from car-data.csv
console.log(cars);
// All of the map info from map-data.json
console.log(map);
// All the dinosaurs from dinosaur-information.csv
console.log(dinosaurs);
}