Homework: Coordinated Views (In Class)

In this exercise you will create a tool using D3 to visualize different aspects of the D3 Les Misérables data. At the end of class post your solution in Piazza as a Blocks + Gist or JS Fiddle under HW5.

Setup

This assignment includes two visualizations:

You will link these visualizations by adding interactions so they can affect each other. To do this, learn about the event handler d3-dispatch (included in d3 v4), which makes communication across visualizations easier. We show some examples of this in class.

To make it easier to get started, we have prepared a starting point (demo, code) with the node-link diagram and the pie chart statically put side by side. Note the use of d3.dispatch: data.js loads the data, and notifies both visualizations that the data is available, which can then use this information independently to render.

First Goal

Use d3.dispatch and the strategies discussed in class to implement the following interactions:

Second Goal

Now, add brushing and linking to the node-link diagram, and use it to re-draw the pie chart to show the distribution of groups among the selected nodes. An example of brushing can be found here.

Take the brush variable, make sure you add the svg layer for the brush (it calls .call(brush)), and then implement a brushended function that detects the nodes within the drawn rectangle, and that tells the pie chart to update via a event dispatch that contains information about the selected nodes.

Stretch Goal

If you still have time in class, include a third visualization:

The interaction is modified thusly:

Examples

Some examples of brushing and linking: