d3.js - kathy zhou (infoscout intern)
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
Introduction to D3.jsKathy Zhou - 2014 InfoScouttern
InfoScout Dev Talks
San Francisco, July 10, 2014
© 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
© 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
© 2014 ScoutIt, Inc.
Kathy Zhou, 2014 InfoScouttern
How D3.js is different
- Crazy!!- But highly practical
- Detailed- Interactive- Engaging
still Nicki Minaj
© 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
© 2014 ScoutIt, Inc.
Kathy Zhou, 2014 InfoScouttern
What can I make with D3.js?
Pretty much anything!
© 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
© 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
© 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
© 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
© 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
© 2014 ScoutIt, Inc.
Kathy Zhou, 2014 InfoScouttern
Make-your-own
~50 lines of javascript~25 lines of html + css
© 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:
© 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
© 2014 ScoutIt, Inc.
Kathy Zhou, 2014 InfoScouttern
Make-your-own
go to http://localhost:8000/to see your D3.js app!
© 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
© 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
© 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?
© 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/
© 2014 ScoutIt, Inc.
Any questions?
Kathy Zhou, 2014 InfoScouttern
Q & A
© 2014 ScoutIt, Inc.
Thank you!!
Kathy Zhou, 2014 InfoScouttern
Q & A
Go forth and D3!!
@kaffkaff^ self-promotion
Pusheen the cat