Dynamic Query
interactionAlso known as: slider filter, checkbox filter, range filter, interactive filter, direct manipulation query
Description
Dynamic queries replace traditional text-based database queries with direct-manipulation GUI widgets — sliders for continuous ranges, checkboxes for categorical inclusion/exclusion, dropdown menus for selecting among options. As the user adjusts a control, the visualization updates immediately (within 100ms, per the original research), providing tight feedback that turns filtering into a fluid, exploratory experience rather than a batch operation.
The concept was pioneered by Ahlberg, Williamson, and Shneiderman (1992) with the FilmFinder system, which used range sliders for year and rating to dynamically filter a scatterplot of movies. Their key contribution was demonstrating that the tight coupling between widget manipulation and visual feedback enables users to rapidly learn the structure of a dataset — discovering correlations, gaps, and outliers through the act of filtering itself. This “query by adjustment” paradigm remains one of the most effective interaction patterns for non-technical users.
Dynamic queries are the “filter” step in Shneiderman’s mantra. Unlike brush selection (which operates in the visual space), dynamic queries operate on data attributes directly. A slider labeled “Year: 1990–2020” makes its semantics explicit, while a brush on a scatterplot requires the user to infer which data dimension is being filtered. This explicitness makes dynamic queries especially valuable in public-facing dashboards and tools designed for domain experts rather than visualization specialists.
When to Use
- When the dataset has clear, interpretable dimensions that the user will want to filter (year, price, rating, category, region).
- When the visualization is aimed at non-technical audiences who would not write SQL or code to filter.
- When real-time feedback during adjustment is important — the user should see the chart change as the slider moves.
- When the number of filterable dimensions is manageable (2-6). More dimensions create interface clutter.
- In dashboards where users need to explore “what if” questions by adjusting parameters.
When NOT to Use
- When the dataset has hundreds of categorical values — a checkbox for each is impractical. Use search or type-ahead instead.
- When the filtering logic is complex (multi-condition joins, nested logic) and cannot be represented by simple widgets.
- When real-time update performance is unachievable due to dataset size or computation cost — lag breaks the interaction loop.
- When the visualization is a static narrative where the author has already chosen the relevant subset.
How It Works
- The interface presents one or more filter controls alongside the visualization: range sliders for numerical/temporal data, checkboxes or toggle chips for categorical data, dropdown menus for selection.
- The user adjusts a control — for example, dragging a range slider to narrow the year range from 1990–2020 to 2005–2015.
- The system immediately filters the underlying data, removing points that fall outside the selected range.
- The visualization re-renders with only the matching data, ideally within 100ms to maintain the perception of direct manipulation.
- Optionally, marks animate out/in to help the user track what changed (see animated-transition).
- A summary indicator (e.g., “Showing 342 of 1,204 items”) gives the user feedback on how selective the current query is.
- Resetting the control (double-clicking the slider, clicking “Reset”) restores the full dataset.
Variations
- Range slider: Two handles define a min-max range for continuous data. The most classic dynamic query widget.
- Single slider: One handle sets a threshold (show all items above/below this value).
- Checkbox bank: Each checkbox toggles visibility of a category. Works well for up to ~12 categories.
- Toggle chips: Compact clickable labels that act like checkboxes but take less vertical space.
- Dropdown / select: For dimensions with many values where only one (or a few) should be active at a time.
- Text search filter: A text input that filters by partial string match. Used for names, labels, IDs.
- Histogram slider: The slider track is overlaid with a histogram of the data distribution, helping the user understand what they are filtering.
Code Reference
// Range slider with Observable Plot / D3
const slider = d3.select("#controls").append("input")
.attr("type", "range")
.attr("min", 2000).attr("max", 2025).attr("value", 2000)
.on("input", function () {
const yearMin = +this.value;
svg.selectAll("circle")
.style("display", d => d.year >= yearMin ? null : "none");
d3.select("#year-label").text(`From ${yearMin}`);
});