Cicero: A Declarative Grammar for Responsive Visualization

Hyeok Kim, Ryan A. Rossi, Fan Du, Eunyee Koh, Shunan Guo, Jessica Hullman, Jane Hoffswell

Abstract

Responsive visualization is critical for the mobile web, yet current tools require either overly broad CSS rules or redundant, manual specification of multiple chart versions. We present Cicero, a declarative grammar that treats responsive design as a series of transformations applied to a source visualization. By using a Specifier-Action-Option structure, Cicero allows authors to concisely define how charts should adapt across screen sizes. We demonstrate Cicero's expressiveness by reproducing 13 complex real-world responsive visualizations from major news outlets, showing significant improvements in code conciseness and reusability.

Introduction

As mobile web traffic continues to dominate, "responsive visualization"—charts that adapt their layout and content to different screen sizes—has become an essential requirement for data storytelling. However, current development tools present a difficult trade-off. Standard web tools like CSS media queries are often too blunt for visualization; they can hide a chart or change its container width, but they cannot intelligently swap a bar chart's axes or reposition a specific data annotation.

On the other end of the spectrum, powerful visualization grammars like Vega-Lite require designers to write entirely separate, complex specifications for every target screen size. This "copy-paste-edit" workflow is tedious, error-prone, and makes it nearly impossible to maintain design consistency when the underlying data or primary design changes. Cicero addresses this gap by introducing a declarative approach focused on transformations rather than individual specifications.

The Cicero Grammar

Cicero treats responsive design as a series of "diffs" or transformations applied to a "source" view (typically the desktop version). A Cicero specification consists of a list of rules, each following a Specifier-Action-Option structure:

  1. Specifier: A query language used to select visualization elements. Authors can select by structure (e.g., "all axis labels"), data (e.g., "marks where year < 2010"), or attributes (e.g., "everything colored red").
  2. Action: A set of high-level predicates that define the transformation. These include modify, reposition, transpose, add, duplicate, remove, replace, and swap.
  3. Option: The specific parameters for the change, such as setting a new font size, a specific x/y offset, or a new data format.
Figure 2: A comparison between standard Vega-Lite and Cicero for transposing axes. Cicero achieves the same result with significantly more concise and readable code.

To support these transformations, the authors developed a compiler for an extended version of Vega-Lite. This compiler is governed by ten principles designed to handle "downstream effects." For example, if a rule filters out a specific data point for a mobile view, the compiler is intelligent enough to automatically remove any text annotations associated with that specific point, maintaining visual integrity without extra user input.

Evaluation and Real-World Use Cases

The authors evaluated Cicero's expressiveness and utility by reproducing 13 diverse, real-world responsive visualization use cases originally published by major news outlets like the New York Times and the Guardian, or found in prior research. These benchmarks span several domains:

  • Economic Data: Bond Yields, Wheat & Wages, and Aid Budget.
  • Public Health & Politics: COVID-19 Spending, French Election results, and Justice Kennedy’s judicial career.
  • Environmental & Disaster Reporting: Oil Spills and Disaster Cost analysis.
Figure 1: The 13 real-world responsive visualization examples reproduced using Cicero, demonstrating the grammar's ability to handle diverse chart types and complex layout changes.

These examples prove that Cicero’s concise syntax can match the output of complex, manually-authored professional visualizations. In the "Bond Yields" case study, a few lines of Cicero code replaced a massive, redundant Vega-Lite specification, highlighting the grammar's efficiency.

Key Insights

Decoupling Selection from Structure

Cicero’s specifiers allow authors to target elements based on their role (such as "legend.mark") rather than their specific location in a JSON tree. This makes transformations "design-agnostic" and highly reusable across different types of charts. A "transpose axes" rule written for a bar chart can often be applied directly to a scatterplot.

Responsiveness as a "Diff"

The core innovation of Cicero is the realization that mobile views should not be defined from scratch. By defining only the changes from the desktop view, the code becomes much shorter and easier to reason about. This approach also simplifies maintenance; if the source data changes, the transformations remain valid.

Smart Defaults and Mimicry

The Cicero compiler doesn't just execute commands; it uses "mimicry" logic to reduce boilerplate. If a user adds a new label to a mobile view, the compiler automatically styles it to match existing labels in the chart, ensuring visual consistency with minimal effort from the designer.

Conclusion and Future Work

Cicero demonstrates that a transformation-based declarative grammar can significantly simplify the creation of responsive visualizations. While the current implementation focuses on static visual changes and relies on a specific Vega-Lite extension, it provides a foundation for future work. Potential areas for expansion include support for responsive interactions (e.g., converting hover tooltips to click menus) and integration with other rendering engines like D3 or ggplot2. Additionally, future iterations could explore "bounded dynamic behavior" similar to CSS Flexbox to allow for more fluid layout adjustments.

Summary updated

BibTeX
@inproceedings{kim2022cicero,
  author = {Hyeok Kim and Ryan A. Rossi and Fan Du and Eunyee Koh and Shunan Guo and Jessica Hullman and Jane Hoffswell},
  title = {{Cicero: A Declarative Grammar for Responsive Visualization}},
  booktitle = {CHI},
  year = {2022},
  doi = {10.1145/3491102.3517455},
}
Figure