François Charih
IEEE EMBS/CMBES Workshop Series
February 6th, 2019
Slides available here: http://charih.ca/workshops/d3-workshop/presentation.html
Data-Driven Documents
D3.js is an open-source Javascript library that provides a convenient interface for building data visualizations in the browser.
Created by Mike Bostock, a graphic designer at the New York Times.
Why would I want to use D3.js?
We accumulate data that is larger in volume and complexity than ever before. Static plots are no longer enough to tell stories which are becoming increasingly complex.
Traditional plotting software (MATLAB, matplotlib, seaborn, etc.) allows you to create visualizations quickly, but leave little room for easy customization.
With D3.js, you build you visualizations from the ground up. D3.js is:
In this example, the center of the waves follows the cursor.
D3.js is a JS library; usage requires some basic knowledge about how webpages are structured/built.
The Hypertext Markup Language allows us to define the hierarchy of the content of a webpage. We refer to it as the DOM Tree. --
Javascript is a language that allows us to modify the DOM Tree dynamically:
SVG is a "language" for vector-based graphics, as opposed to raster-based graphics. As such, it can be scaled to arbitrary sizes without loss in quality.
SVG has a similar syntax to HTML, but defined geometric elements: circles, rectangles, lines, paths, polylines.
JSON is a data interchange format. It allows us to group and organize data.
A JSON document is simply a list of key-value pairs.
// Accessing a value var firstName = jsonObject.firstName; var age = jsonObject["age"];
// A JSON object reprenting a person { "firstName": "John", "lastName": "Smith", "isAlive": true, "age": 27, "address": { "streetAddress": "21 2nd Street", }, "phoneNumbers": [ { "type": "home", "number": "212 555-1234" } ] }