
The Patterns 309
Why
First, Dynamic Queries are easy to learn. No complicated query language is necessary at the
user’s end; well-understood controls are used to express common-sense Boolean expres-
sions such as “price > $70 AND price < $100”. They lack the full expressive power of a query
language—only simple queries are possible without making the UI too complicated—but in
most cases, that’s enough. It’s a judgment call you have to make.
Second, the immediate feedback encourages open-ended exploration of the data set. As
the user moves a slider thumb, for instance, she sees the visible data contract or expand.
As she adds or removes different subsets of the data, she sees where they go and how
they change the display. She can concoct long and complex query expressions incremen-
tally, by tweaking this control, then that, then another. Thus, a continuous and interactive
“question and answer session” is carried on between the user and the data. The immediate
feedback shortens the iteration loop so that exploration is fun and a state of flow is pos-
sible. (See Chapter 1,
Incremental Construction.)
Third—and this is a little subtler—the presence of labeled dynamic-query controls clari-
fies what the queryable attributes are in the first place. If one of the data attributes is a
number that ranges from 0 to 100, for instance, the user can learn that just by seeing a
slider that has 0 at one end and 100 at the other end.
How
The best way to design a dynamic query depends on your data display, the kinds of que-
ries you think should be made, and your toolkit’s capabilities. As mentioned, most pro-
grams map data attributes to ordinary controls that live next to the data display. This
allows querying on many variables at once, not just those encoded by spatial features on
the display. Plus, most people know how to use sliders and buttons.
Other programs afford interactive selection directly on the information display. Usually
the user draws a box around a region of interest and the data in that region is removed (or
retained while the rest of the data is removed). This is manipulation at its most direct, but
it has the disadvantage of being tied to the spatial rendering of the data. If you can’t draw
a box around it—or otherwise select points of interest—you can’t query on it! See the
Data
Brushing
pattern for the pros and cons of a very similar technique.
Back to controls, then: picking controls for dynamic queries is similar to the act of picking
controls for any kind of form—the choices arise from the data type, the kind of query to
be made, and the available controls. Some common choices include:
• Sliders to specify a single number within a range.
• Double sliders or slider pairs to specify a subset of a range: “Show data points that are
greater than this number, but less than this other number.”