Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var loadJSON = d3.json("/json/zips_us_topo.json");
- var dataJSON = d3.json("/json/CustomersByZip.json",
- function(d){
- zipcodeData.set(d.Zipcode, d.TotalPatients,d.ColorHex);
- });
- //Promise
- Promise.all([loadJSON, dataJSON]).then(addZips).catch(console.log.bind(console));
- function addZips([us]) {
- var myJSON = JSON.stringify(us);
- console.log(myJSON.substring(0,200)); // Returns first 200 characters of loadJSON file, so I know I can just reference it with "us".
- console.log(dataJSON); // displays "Promise {<resolved>: {...}}
- console.log(loadJSON); // displays "Promise {<resolved>: Array(28355)}" so it loaded the dataJSON data but how do I reference it?
- console.log(us[0]); // displays "undefined"
- console.log(us[1]); // displays "undefined"
- console.log(us[0][0]); // TypeError: Cannot read property '0' of undefined
- console.log(us[1][0]); //TypeError: Cannot read property '0' of undefined
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement