O'Reilly logo

Data Visualization: Representing Information on Modern Web by Swizec Teller, Ændrew Rininsland, Simon Timms, Andy Kirk

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving data

Before we go about retrieving data we should probably decide what data we wish to visualize. The amount of data which is available about the logged in user is not all that great (at least it isn't for me but I hardly use Facebook). That leaves us with looking at our friends. I found devices my friends use to access Facebook to be quite interesting. Are they more Android users or iOS? This information is available as part of the friends' collection. To retrieve this information we can use the FB.api() method:

FB.api('/me?fields=friends.fields(devices)', function(response){ for(i = 0; len = response.friends.data.length; i< len; i++){ var friend = response.friends.data[i]; if(friend.devices) for(j = 0; j< friend.devices.length; j++) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required