October 4, 2016

D3 Wrap-up and Big Data

Today's Schedule

  • Review last week's homework
  • Finish D3 Lesson
  • Homework
  • Data Stored in Files
  • APIs

Presentation Time

http://www.dave-landry.com/classes/artg4552-2016/random/

D3 Continued

Let's finish our Enter/Update/Exit lesson from last week, which again is based on this great tutorial: https://bost.ocks.org/mike/circles/.

Homework

Create a presentation pitching your final project.

  • Find an open dataset that interests you and has at least 500 data points (ie. rows).
  • Outline the different variables available in the dataset.
  • Sketch/describe some ideas on how you could visualize that data.
  • Post your pitch on your GitHub website and be prepared to discuss it next week.

Data Stored in Files

External Files

Just like CSS and JS, data can be stored in external files and loaded into the page dynamically!

Filetypes

D3 comes with functions that can read in external data files automagically. Filetypes include:

  • .txt
  • .csv
  • .tsv
  • .json

.txt

Reads text in as a string. 'Nuff said.

d3.text(file, function(error, data) {

});

.csv

Comma-separated values. Each line of the file is a data object, with it's values separated by commas.

The first row in the file is expected to be the key names for each data point.

d3.csv(file, function(error, data) {

});

.tsv

The same as .csv, except with tabs instead of commas!

d3.tsv(file, function(error, data) {

});

.json

JavaScript Object Notation. Data is stored with the same syntax as it would be in Javascript, with keys and values.

d3.json(file, function(error, data) {

});

Questions?

API

"application programming interface"

What is an API?

In the context of data, developers who store data in databases need to enable an easy way for themselves and others to extract data based on specific query parameters.

Shameless Example

Data USA

Data USA hosts data from 7 different public US datasets.

Additionally, they've published an open API for all of the data. Documentation is here.

Loading from an API

Data from an API is commonly delivered as JSON, so instead of giving d3.json a filename, we can give it a URL:

var url = "https://api.datausa.io/api/?required=income&show=geo&sumlevel=state";

d3.json(url, function(error, data) {

});

Questions?

Homework

Create a presentation pitching your final project.

  • Find an open dataset that interests you and has at least 500 data points (ie. rows).
  • Outline the different variables available in the dataset.
  • Sketch/describe some ideas on how you could visualize that data.
  • Post your pitch on your GitHub website and be prepared to discuss it next week.