THINK FIRST·CODE LATER

← Interactive Information Visualization
Chapter 8 · Week 8

Interaction and Multiple Linked Views

Before You Start: What You Must Be Able to Do

Before the questions, make sure you can: justify when interaction is worth its cost; classify interaction techniques (change, select, navigate; juxtapose, partition, superimpose; overview + detail, focus + context); build linked views in Altair with interval and point selections, legend and widget bindings, conditions and filters, and predict what a linked view shows for a given selection; build an interactive Bokeh 3 figure with a data source, hover tool and widget callback; choose a level of detail for zooming; and explain the human time limits that interaction must respect.

The Big Idea

A static chart answers one question; an interactive one lets the user ask the next. Interaction is how visualization handles more data than fits on a screen and more tasks than one view supports — but every click, hover and drag costs time and attention. The design question is not "can I add interaction?" (AI tools add sliders and tooltips by default) but "which task does this interaction serve, and is it cheaper than another view?" The most powerful pattern of the semester is linked views: select in one chart, see the consequence in another.

Why interact?

  • Scale: 80 stations × 288 snapshots a day cannot be shown at once; filtering, zooming and aggregation on demand can.
  • Multiple tasks: the same tool must support overview, locate, identify and compare (the chain of Chapter 3).
  • Exploration: discovery means asking questions you did not plan for.

Shneiderman's mantra is an interaction recipe: overview first, zoom and filter, then details on demand.

Manipulating a view

Technique Examples
Change over time switch the attribute shown (PM2.5 ↔ temperature), re-sort, change aggregation level, animate
Select click, lasso or brush items; the selection is then highlighted, filtered or used elsewhere
Navigate zoom and pan (geometric), semantic zoom (show more detail — labels, finer aggregation — when zoomed in), constrained navigation
Details on demand tooltips, side panels, drill-down

Tooltips are cheap and useful, but they hide information until hovered — and do not work on touch screens without tapping. Never put essential information only in a tooltip.

Faceting into multiple views

  • Juxtapose — views side by side: different idioms on the same data (a map and a time series), or the same idiom on different data.
  • Partition — split the data into regions: small multiples by district, grouped bars.
  • Superimpose — layers in the same frame: a line plus a reference rule, a highlighted series over grey context.

Coordinated multiple views share data, encoding or navigation: selecting a district in a map highlights its line in a time series (linked highlighting); zooming one time axis zooms all of them (shared navigation).

Brushing and linking (Becker & Cleveland, 1987): drag an interval (a "brush") in one view; the other views highlight or filter to the brushed items. In Lab V8.1, brushing 2–3 March in the timeline changes the bar chart of means from Lucheng 51.5 to 58.0 µg/m³ — the linked view answers "what happened in that period?".

Overview + detail shows a small overview with an indicator of the current zoom window next to a detailed view; focus + context (e.g., fisheye) enlarges a region while keeping its surroundings visible but compressed.

Interaction in Altair

Altair (Vega-Lite) expresses interaction declaratively with parameters:

brush = alt.selection_interval(encodings=["x"])                  # drag on the time axis
pick = alt.selection_point(fields=["district"], bind="legend")    # click legend entries

timeline = alt.Chart(df).mark_line().encode(
    x="date:T", y="pm25:Q",
    color=alt.condition(pick, "district:N", alt.value("lightgray"))  # highlight
).add_params(brush, pick)

bars = alt.Chart(df).mark_bar().encode(
    x="district:N", y="mean(pm25):Q"
).transform_filter(brush)                                           # filter by the brush

timeline & bars
  • selection_point — clicked items (or values of fields); selection_interval — a dragged rectangle or range.
  • bind="legend", bind=alt.binding_select(options=[...]), alt.binding_range(min, max) (slider), alt.binding_radio — widgets with no server needed.
  • alt.condition(sel, if_true, if_false) — encode differently inside/outside the selection; transform_filter(sel) — keep only selected data.
  • .interactive() — pan and zoom by binding an interval selection to the scales.

The specification records it all: a params list with the selection definitions and {"filter": {"param": "brush"}} in the linked view — so you can inspect and test interaction logic like everything else.

Plotly and Bokeh

Plotly Express gives interaction by default (hover, zoom, pan, legend toggling): px.line(df, x="date", y="pm25", color="district", hover_data=["temperature"]). Dash turns Plotly figures into web apps with Python callbacks (Chapter 9).

Bokeh builds browser-based figures from models: a ColumnDataSource holds the data, glyph methods (line, scatter, vbar) draw it, tools (HoverTool, BoxZoomTool) add interaction and widgets (Select, Slider) control it. Two kinds of callbacks:

  • CustomJS — JavaScript that runs in the browser; the result is a standalone HTML file (output_file + show, or save).
  • Python callbacks (widget.on_change(...)) — need a running Bokeh server (bokeh serve app.py, using curdoc()).

Bokeh 3 changed the API: figure(width=…, height=…) replaces the removed plot_width/plot_height, and scatter(size=…) replaces circle(size=…) (deprecated in 3.4). Many tutorials — and AI assistants trained on them — still use the old names; Lab V8.3 rebuilds a classic sales-dashboard case study correctly.

Time limits and level of detail

Interaction must respect human time constants (Card; Nielsen): about 0.1 s feels instantaneous (needed for brushing and hovering), 1 s keeps the flow of thought (clicks, filters), 10 s is the limit of attention (show progress for longer operations). Brushing over 2 million raw points in the browser will not meet 0.1 s — aggregate, pre-compute, or use server-side tools (datashader, VegaFusion).

When zooming over time, change the level of detail: a 10-year view of 5-minute data has 1 million points for 800 pixels; aggregate per week (≈ 520 points) and switch to hourly or 5-minute data as the user zooms in (Lab V8.4) — semantic zoom.

Animation vs. small multiples

Animation (the famous Gapminder bubbles) is engaging for presentation, but for analysis it forces viewers to remember previous frames: Robertson et al. (2008) found small multiples and traces more accurate than animation for trend analysis. Use animation to tell, small multiples to compare.

Industry spotlight

Observability platforms (Grafana, Datadog, Kibana) are built around linked interaction: brushing a time range on one panel sets the range of every panel on the dashboard, and clicking a spike drills down to logs. The pattern is the same as Lab V8.1 — and it is what on-call engineers use at 3 a.m. (Chapter 13).

Research spotlight

Interaction logs are research data: studies analyse sequences of user interactions to infer tasks, detect confusion or recommend next views; "provenance" research records analysis histories for reproducibility. With AI, natural-language interaction ("only show weekends", "why is this high?") is becoming another way to change a view — with the same need to make the state visible and undoable.

Key takeaways

  • Interact to handle scale, multiple tasks and exploration — each interaction must serve a task and be worth its cost.
  • Manipulate (change, select, navigate, details on demand); facet (juxtapose, partition, superimpose); coordinate views (linked highlighting, brushing and linking, shared navigation); overview + detail, focus + context.
  • Altair: selection_point / selection_interval, bindings (legend, select, range), alt.condition, transform_filter, .interactive(); all visible in the spec's params.
  • Bokeh 3: ColumnDataSource + glyphs + tools + widgets; CustomJS = standalone HTML, Python callbacks = Bokeh server; width/height, scatter.
  • 0.1 s / 1 s / 10 s; change the level of detail when zooming; animation for telling, small multiples for analysis.

Ready? Close the notes and practise.

30 questions. Predict the output before you check — that is the skill the exam measures.