Creating the perfect data visualization is often a two-front war. On one side, you have the "visual" challenge: choosing the right marks, colors, and scales in libraries like ggplot2 or Vega-Lite. On the other, you have the "wrangling" challenge: reshaping, aggregating, and cleaning the raw data so those libraries can actually digest it.
This paper introduces Viser, a tool that lets users skip the manual labor by synthesizing full visualization scripts from a simple "visual sketch."
TL;DR
Viser is a program synthesis tool that generates end-to-end visualization code (data transformation + plotting) from a small, user-provided visual example. By decomposing the problem into two sub-tasks and using bi-directional program analysis, it can solve complex real-world visualization problems in seconds.
What Problem Does This Paper Address?
Most "Programming by Example" (PBE) tools for data are specialized. Some help you reshape tables (like FlashFill), while others recommend plots based on a clean dataset. However, in the real world, these tasks are inextricably linked. You can't make a stacked bar chart if your data isn't pivoted correctly, but you don't know how to pivot the data until you've decided on the chart type.
The authors identify three main hurdles:
- The Expertise Gap: Users need deep knowledge of both data manipulation (dplyr/tidyr) and visualization (ggplot2) APIs.
- The Formatting Loop: Different plots require different data shapes, leading to tedious trial-and-error.
- The Synthesis Complexity: Trying to guess a data-transformation program and a visualization program simultaneously creates a search space so massive that standard synthesis techniques choke.
Methods
The "secret sauce" of Viser is its compositional synthesis approach. Instead of searching for one giant program, it breaks the task into two parts:
- Visual Program Synthesis: Given a sketch (e.g., "I want a point at (1,7) and (2,6) with label 'M'"), Viser first guesses the type of plot and the necessary columns. It produces a "visual program" and an intermediate specification.
- Table Transformation Synthesis: This is where the heavy lifting happens. Viser takes the intermediate spec—expressed as table inclusion constraints ($T \subseteq^\diamond t$)—and searches for a sequence of operations (join, mutate, gather, spread, etc.) that transforms the raw input into a table satisfying those constraints.
To make this efficient, the authors use Bi-directional Program Analysis.
- Forward Analysis: It looks at the current partial program and asks, "What kind of table could this produce?"
- Backward Analysis: It looks at the desired sketch and asks, "What must the input table look like for this to work?" By intersecting these two perspectives, Viser can prune millions of invalid programs instantly, focusing only on the ones that are mathematically capable of producing the user's sketch.
Datasets
The authors evaluated Viser on 83 real-world visualization tasks curated from:
- Online Tutorials: 63 tasks from highly-reputed Excel and Vega-Lite tutorials.
- StackOverflow: 20 tasks from the
ggplot2sub-forum where users asked "How do I plot this?" - Input Variety: The datasets ranged from tiny tables to files with nearly 4,000 rows, covering subplots, multi-layered charts, and complex aggregations.
Key Insights and Ideas
- The Sketch as a "Visual Trace": Viser treats a user's sketch not just as an image, but as a set of symbolic constraints. This allows the system to understand that a point at (1,7) implies the existence of a row where some column $x=1$ and $y=7$.
- Decomposition is Mandatory: The paper demonstrates that without splitting the task into visual and table sub-problems, the success rate drops from 84% to 60%, and the time taken skyrockets.
- Incomplete Specs are a Feature: The use of "table inclusion constraints" is brilliant because it acknowledges that the user's sketch is partial. The final table might have 100 columns, but if the sketch only uses 3, the synthesizer shouldn't be penalized for the other 97.
Key Results
- High Success Rate: Viser solved 84% of the benchmarks within a 10-minute timeout.
- Speed: Many tasks were solved nearly instantly; 31% were solved in under one second, and 59% in under 10 seconds.
- Ranking Accuracy: In 70% of the solved cases, the user's desired visualization was among the top-5 results generated by the tool.
- Comparison: Viser significantly outperformed Morpheus, a state-of-the-art table synthesis tool, primarily because Morpheus lacks the bi-directional pruning necessary for the "loose" specifications found in visualization tasks.
Limitations and Future Work
- Scalability with Table Width: As the number of columns in the input table grows, the search space for transformations expands exponentially. Very "wide" datasets remain a challenge.
- Complex Logic: Viser struggles with transformations requiring complex string manipulation (regex) or advanced math that isn't covered by its DSL.
- UI Integration: Currently, the "sketch" must be provided in a semi-formal way. The authors suggest that integrating Viser with a GUI-based drawing tool (like Lyra) would make it much more accessible to non-programmers.
- Continuous Functions: The current DSL doesn't handle visualizations involving continuous mathematical functions or non-standard coordinate systems (like tree-maps).
Summary updated