d3.js - kathy zhou (infoscout intern)

21
Introduction to D3.js Kathy Zhou - 2014 InfoScouttern InfoScout Dev Talks San Francisco, July 10, 2014

Upload: kathy-zhou

Post on 08-May-2015

502 views

Category:

Software


2 download

DESCRIPTION

Want to learn more about D3.js, the Javascript data visualization library? Want to build a D3 interactive network visualization in 30 minutes? Check out the slides from Kathy Zhou's talk at InfoScout on July 10, 2014 :)

TRANSCRIPT

Page 1: D3.js - Kathy Zhou (InfoScout intern)

Introduction to D3.jsKathy Zhou - 2014 InfoScouttern

InfoScout Dev Talks

San Francisco, July 10, 2014

Page 2: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What is D3.js?

D3 stands for Data Driven Documents- client-side Javascript charting library- for data visualization in web applications

Page 3: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Other Javascript Charting Libraries

- Highcharts.js- Chart.js- CanvasJS

- Nice and proper :)- Appropriate for most occasions- Easy to learn

- Limited interactivity- Hard to modify/build upon

Nicki Minaj

Page 4: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

How D3.js is different

- Crazy!!- But highly practical

- Detailed- Interactive- Engaging

still Nicki Minaj

Page 5: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What can I make with D3.js? Examples:

← Sunburst DiagramsGood for funnel data

Force-directed graphs → Network data

← Chord diagramAffinities, group associations

Page 6: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What can I make with D3.js?

Pretty much anything!

Page 7: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

How does D3 work?

- one 8,000-line Javascript file uncompressed!- Built on top of existing web technologies

image source: jolicharts.com

Page 8: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

How does D3 work?

<svg> tags are tags in HTML5 (the latest version of HTML): elements on the page made up of circles, rectangles, textboxes, etc.

^ basic shapes and text is what D3 boils down to

image source: googlecode.blogspot.com

Page 9: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What I’ve done with D3 so far

Cooccurrences diagram- highly developed chart to show brand affinities

- used for clients Unilever and Coty (I made us money :D)- the chart rearranges itself alphabetically and by affinity- hover effects: shows percentages, all statistics for one brand

Page 10: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What I’ve done with D3 so far

Category seasonality- heatmap to show most popular days of the week in purchasing

- displays product popularity by day of week, day of month, day of year

Page 11: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

What I’ve done with D3 so far

Trip Circuits - what percent of consumers buy a product in what order?- like a pie chart, but more robust to include funnel dataex. 0.6% buys Huggies and then Pampers in one time period

Page 12: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

~50 lines of javascript~25 lines of html + css

Page 13: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

link to html file: http://pastebin.com/R4VHS9BM

link to json file: http://pastebin.com/18SE2EpY

your source directory should look like this:

Page 14: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

type this command in the folder of your project:

python -m SimpleHTTPServer

you should see this message in your terminal

Page 15: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

go to http://localhost:8000/to see your D3.js app!

Page 16: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

Adding more ‘people’- add a

{"name":"<name>","group":<group_no>}

to the “nodes” list in force.json

Adding more links- the numbers in “source” and “target” correspond to the indices of the people in the “nodes” list- the “value” corresponds to the stroke color

Page 17: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Make-your-own

Changing node affinity:- line 33 in index.html

Changing edge length- line 34 in index.html

Changing node size:- line 61 in index.html

Page 18: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

1. Interesting front-end challenge2. Can create more interactive and visually appealing data analytics tools

- make revenue :D3. Helps solve interesting problems in data science

- graph theory- associations- geographical, etc.

Kathy Zhou, 2014 InfoScouttern

Summary: Why should I used D3?

Page 19: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Kathy Zhou, 2014 InfoScouttern

Where do I go from here?

If you’re inexperienced with web, look into using Highcharts or charts.js first

http://www.highcharts.com/

For building on existing visualizationshttps://github.com/mbostock/d3/wiki/Gallery

More on how it workshttp://alignedleft.com/tutorials/d3/

Page 20: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Any questions?

Kathy Zhou, 2014 InfoScouttern

Q & A

Page 21: D3.js - Kathy Zhou (InfoScout intern)

© 2014 ScoutIt, Inc.

Thank you!!

Kathy Zhou, 2014 InfoScouttern

Q & A

Go forth and D3!!

@kaffkaff^ self-promotion

Pusheen the cat