create neat interactive visualisations

36
DUBLIN DATA VISUALISATION MEETUP #DUBLINDATAVIS (21 ST MAY 2013) © Eamonn O’Loughlin Create Rich Interactive Visualisations

Upload: eamonn-oloughlin

Post on 19-Jan-2015

1.036 views

Category:

Education


5 download

DESCRIPTION

Using dc.js to create rich, interactive web data visualisations - 1 hour tutorial / session. You will leave this session with an appreciation of how easy it is to use standard javascript libraries to create really rich web visualisations that can easily be shared across teams. It is possible to build an interactive dashboard that visualises csv, excel, database file in less than an hour. We will start this session with a basic csv file of data. We will finish with everyone having created an interactive visualisation similar to the screenshot below. All welcome. Prerequisites: (1) basic understanding of html & javascript

TRANSCRIPT

Page 1: Create Neat Interactive Visualisations

DUBLIN DATA VISUALISATION MEETUP

#DUBLINDATAVIS (21ST MAY 2013)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 2: Create Neat Interactive Visualisations

WHY DID WE CREATE THIS MEETUP?

A community for those interested in creating, sharing, discussing or learning how to create data-driven visualisations. Fighting the good fight against a massive data deluge.

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 3: Create Neat Interactive Visualisations

EVENTS WE’D LIKE TO HOST Walkthroughs (like this one) Short sharing sessions Discussions on technologies

Visualisation ‘Cook-Off’ (for fun!)

Share Neat Visualisations

Share Visualisation Stories (when it worked / why it worked)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 4: Create Neat Interactive Visualisations

CREATE RICH INTERACTIVE DATA VISUALISATIONS EAMONN O’LOUGHLIN

#DUBLINDATAVIS (21ST MAY 2013)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 5: Create Neat Interactive Visualisations

EAMONN O’LOUGHLIN 6 years as Management Consultant / Analytics Consultant Developing / implementing insight-generating solutions (customer segmentation, loss-default forecasting, business event simulation, operations strategy) Researching behaviour through the lens of Social Network Analysis (Dynamics Lab at UCD) Interested in visualisation of dynamic social networks, algorithms, web application frameworks, mobile device interaction, collaboration technologies @ieeamo / http://www.linkedin.com/in/eamonnoloughlin

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 6: Create Neat Interactive Visualisations

RICH INTERACTIVE VISUALISATIONS Accessible in browser Interactive Scalable to moderate-sized datasets (~1M rows)

Easy / Quick to Implement

Flexible

Enables Rapid Prototyping

Encourages Data Exploration

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 7: Create Neat Interactive Visualisations

WHAT TODAY IS NOT ABOUT Enterprise Solution Scalable to ‘Big Data’ Unique Visualisations

Extensive Customisation

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 8: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation*

Tidy and Wrap Up

*This is the hardest part

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 9: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 10: Create Neat Interactive Visualisations

TODAY WE WILL BE USING Web Server dc.js Bootstrap

Note: dc.js is built on top of d3.js and crossfilter.js

(so we will only be using these indirectly)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 11: Create Neat Interactive Visualisations

D3.JS “D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components.” Developed by Mike Bostock (Graphic Editor of New York Times)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 12: Create Neat Interactive Visualisations

CROSSFILTER.JS “Crossfilter is a JavaScript library for exploring large multivariate datasets in the browser. Crossfilter supports extremely fast (<30ms) interaction with coordinated views, even with datasets containing a million or more records.” Built to power analytics for Square Register, allowing merchants to slice and dice their payment history fluidly.

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 13: Create Neat Interactive Visualisations

DC.JS “dc.js is a javascript charting library with native crossfilter support and allowing highly efficient exploration on large multi-dimensional dataset. It leverages d3 engine to render charts in css friendly svg format.” Developed by Nick Qi Zhu at Thoughtworks to perform data visualization and analysis in browser as well as on mobile device

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 14: Create Neat Interactive Visualisations

BOOTSTRAP “Sleek, intuitive, and powerful front-end framework for faster and easier web development. Bootstrap was made to not only look and behave great in the latest desktop browsers, but in tablet and smartphone browsers via responsive CSS as well.” Developed by a team at Twitter.

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 15: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 16: Create Neat Interactive Visualisations

YELP KAGGLE CHALLENGE

Download the yelp test set

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 17: Create Neat Interactive Visualisations

YELP KAGGLE CHALLENGE

yelp_test_set_business.json

© Eamonn O’Loughlin

Create rich interactive visualisations of your data

Page 18: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 19: Create Neat Interactive Visualisations

DATA STRUCTURE

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 20: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 21: Create Neat Interactive Visualisations

DC.JS LIBRARY

Bubble Chart Line Chart

Pie Chart

Row Chart Bar Chart

Data Table

Choropleth Map

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 22: Create Neat Interactive Visualisations

DESIGN OUR VISUALISATION

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 23: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 24: Create Neat Interactive Visualisations

IMPLEMENTATION 3 Stages to Implement 1.  Development Environment

2.  HTML

3.  JavaScript

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

+ +

Page 25: Create Neat Interactive Visualisations

SIMPLE STEP-BY-STEP APPROACH Development Environment 1.  In a new folder create index.html, simple_vis.js

2.  Copy yelp data and components (js/css) into folder

3.  Start web server (mongoose) from folder

4.  Open browser to url localhost:8080

5.  Open javascript console

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Walk through steps during presentation

Page 26: Create Neat Interactive Visualisations

SIMPLE STEP-BY-STEP APPROACH HTML •  Setup simple structure

•  <head> •  <body>

•  Load javascript libraries (d3, crossfilter, dc)

•  Load stylesheets (dc)

•  Setup <div> placeholders

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Walk through steps during presentation

Page 27: Create Neat Interactive Visualisations

SIMPLE STEP-BY-STEP APPROACH JavaScript (simple_vis.js) 1.  Load Data

2.  Create Chart Object(s)

3.  Run Data Through Crossfilter

4.  Create Data Dimensions & Groups

5.  Implement Charts

6.  Render Charts

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Walk through steps during presentation

Page 28: Create Neat Interactive Visualisations

SEGWAY #1 DIMENSIONS / GROUPS Dimension Returns ordered (and cached) data based on selected variable from the underlying data Group

Return aggregation of the data, based on chosen dimension. Typical examples include:

•  ReduceSum (sum the values)

•  ReduceCount (count of items)

•  Reduce (custom) – describe what happens aggregation when items are added / removed from group

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 29: Create Neat Interactive Visualisations

SEGWAY #2 CHAINING Majority of dc functions are designed to allow function chaining, meaning it will return the current chart instance whenever it is appropriate.

Therefore configuration of a chart can be written in the following style:

myChart.width(300)!

! .height(300)!

! .filter("sunday");!

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 30: Create Neat Interactive Visualisations

WHAT WE’RE GOING TO DO Quick Review of underlying components Download a dataset Explore the Data Structure

Design our Visualisation (Rough Plan)

Iteratively Implement our Visualisation

Tidy and Wrap Up

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 31: Create Neat Interactive Visualisations

SEGWAY #3 BOOTSTRAP FLUID NESTING

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Page 32: Create Neat Interactive Visualisations

© Eamonn O’Loughlin

Create rich interactive visualisations of your data

Page 33: Create Neat Interactive Visualisations

FINAL VISUALISATION (HERE)

© Eamonn O’Loughlin

Create Rich Interactive Visualisations

Code

Page 34: Create Neat Interactive Visualisations

© Eamonn O’Loughlin

Create rich interactive visualisations of your data

Page 35: Create Neat Interactive Visualisations

THAT’S IT. THANK YOU

© Eamonn O’Loughlin

Create rich interactive visualisations of your data

Blue Dog Images from blog of Wendy Rodrigue

Page 36: Create Neat Interactive Visualisations

THAT’S IT. THANK YOU

© Eamonn O’Loughlin

Create rich interactive visualisations of your data

Blue Dog Images from blog of Wendy Rodrigue

What questions /

comments do you have?