The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

puckdoug (4) [Avatar] Offline
#1
“In both cases, the results of loading the data file is an array of JSON objects, though in the case of tweets.json, this array is found at data.tweets, while in the case of cities.csv, this array is data. ”

Why are data for cities.csv and data.tweets for tweets.json? This doesn't seem to be explained in the API docs.
elijah.meeks (127) [Avatar] Offline
#2
Re: Unexplained difference in loading data in section 2.2.1
I'll explain this in more detail in chapter 2. Basically, d3.json() allows you to load a JSON-formatted file, which means it can have objects and attributes in a way that a loaded CSV cannot. When I load a CSV, it returns an array of objects, which in this case is initialized as "data". When I load a JSON file, it could return an object with several name/value pairs. In this case, the object that is initialized as "data" has a name/value pair of "tweets": [Array of Data].

That's why you need to refer to data.tweets after you've loaded tweets.json, but refer to data when you load cities.csv. I actually set up the structure of tweets.json to highlight this distinction.

Let me know if that makes sense--I'll include this the next time I edit Chapter 2.
puckdoug (4) [Avatar] Offline
#3
Re: Unexplained difference in loading data in section 2.2.1
Yes, that makes it perfectly clear.

Thanks!