4. Web Sockets and Data
Visualization
Today we’ll look at:
• Data Collection and Consumption
• Data Analytics and Visualization
• Event Driven, bi-directional data via Websocket
• Data Visualization via DOM manipulation
• Case Study: Creating a simulation
6. Data Collection and
Consumption
• Devices that connect to the Internet are constantly
sending and receiving data.
• You should ask yourself:
• What do we collect?
• What do we present to the user?
• How do we influence user behavior?
• How do we allow for user feedback?
8. Data Collection and
Consumption
• User focus is on tactical / real-time data
• Data should be bi-directional
• Expend your resources wisely
• Breadth < Speed < Data Quality
9. Data Collection and
Consumption
Analytical Tactical
Requires wide breadths of data Values speed over volume
Is not time sensitive
Should be as close to real time as
possible
Is used to to make long term
decisions
Should allow you to make quick
decisions with immediate feedback
Bifurcate your data (real-time and long-term)
10. Data Analytics and
Visualization
Things I learned from a spy - The DADA loop:
• Data
• Analysis
• Decision
• Action
• Repeat
Image Src: http://static.digit.in/fckeditor/uploads/spy_vs_spy_by_kurosama_76-d5kgjml.jpg
11. Data Analytics and
Visualization
• Data: API, server
• Analysis: visualizations, analytics, dashboards
• Decision: indicators, color, alerts, messages
• Action: interactive elements
• Repeat: data returned to the server, new data sent
12. Websocket and bi-
directional data
WebSockets is an advanced technology that makes it
possible to open an interactive communication session
between the user's browser and a server. With this API, you
can send messages to a server and receive event-driven
responses without having to poll the server for a reply.
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
13. Websocket and bi-
directional data
Traditional (Polling / AJAX) Modern (Messaging/Websocket)
Pulls data asynchronously Bi-directional / Interactive
REST APIs are widely available
Widely supported in modern
browsers
Read once / use many Event Driven
16. Data Visualization via DOM
Manipulation
D3.js
• Uses SVG, HTML, and CSS
• Bind data to the DOM
• Web Standards based
17. Data Visualization via DOM
Manipulation
Structuring your application
• init: This is where you create your scales, ranges, domains, as well
as binding your data to the DOM element that is going to use it.
• enter: This is the initial, static visualization. Here you will assign
attributes and values to the different components of your element.
• update: Here you will update any of the dynamic attributes of your
graph if the user changes the context or scope of your data.
• exit: Any cleanup.
18. Data Visualization via DOM
Manipulation
Your basic D3 Starter Kit
• Define the dataset [1]
• Create a container [3-5]
• Bind your data [8]
• Append visual
components & set
attributes [11-18]
• Clean up [24]
20. Data Visualization via DOM
Manipulation
Creating your API
Simple,
Reusable,
Immutable,
Scalable,
DRY
21. Data Visualization via DOM
Manipulation
Listeners for triaging
data
Massage data before
passing to interface
Control the subset
Manage your SVG
elements
24. Case Study: Building a
Simulation
• Server: wait for client, handshake, data
• Client: handshake, listen for updates
• Visualization: present the data in a meaningful way
• Input: send new information to the server