ChartMark: A Structured Grammar for Chart Annotation

Yiyu Chen, Yifan Wu, Shuyu Shen, Yupeng Xie, Leixian Shen, Hui Xiong, Yuyu Luo

Introduction

ChartMark is a new, language-agnostic grammar designed to standardize how we describe chart annotations—such as highlights, trend lines, and data labels. By decoupling the semantic intent (the "what" and "why") from the specific rendering library (the "how"), it enables reusable, modular, and platform-independent visual storytelling. It aims to serve as the "Grammar of Graphics" specifically for the annotation layer, addressing the fragmentation currently found in visualization tools.

The Problem: Fragmented Annotations

Annotations are the "narrative tissue" of data visualization; they guide the viewer's eye, provide context, and highlight critical patterns. However, the current landscape is highly fragmented. An annotation created in D3.js cannot be easily ported to Vega-Lite or ECharts because most tools treat annotations as "hard-coded" visual primitives (like a line at a specific pixel coordinate) rather than semantic entities (like "a line representing the mean of Category A"). This tight coupling makes annotations difficult to reuse, share, or automate across different platforms.

The ChartMark Framework

The authors propose a hierarchical, JSON-based framework that organizes annotations into five distinct semantic layers:

  1. Chart Context: Defines base chart properties like type, axes, and data sources.
  2. Task: Captures high-level intent (e.g., highlight, summary, trend).
  3. Data: Specifies the reference, which can be internal (existing points), external (images/text), or derived (statistical aggregates).
  4. Operation: Defines the specific tactic used to realize the task (e.g., add_stroke, label_line).
  5. Target & Marker: The atomic level where visual elements (lines, text, symbols) and properties (color, opacity) are defined.
The structural components of the ChartMark grammar and its rendering pipeline.

Implementation and Expressiveness

The researchers implemented this grammar in a Python toolkit called ChartMark.py, which acts as a compiler transforming abstract specifications into renderable Vega-Lite code. To evaluate the grammar's expressiveness, the authors demonstrated its ability to handle diverse and complex scenarios across various visualization types, including grouped bar charts and scatter plots.

A complete ChartMark instance showing how semantic annotations are defined and rendered on a grouped bar chart.

As shown in the example above, ChartMark can simultaneously handle multiple annotation tasks—such as highlighting specific categories, labeling values, and drawing statistical summary lines—within a single structured specification.

Key Insights

  • Decoupling Semantics from Implementation: By treating an annotation as a portable data structure, the system can automatically update annotations even if the underlying data changes. For instance, a "highlight maximum" instruction will always find the correct bar.
  • Multi-level Representation: Distinguishing between intent (Task) and tactic (Operation) provides both high-level meaning and low-level control for the user.
  • Atomic Element Design: Breaking annotations into reusable "atomic" actions (like Set Color) reduces redundancy and allows for the creation of complex custom effects without bloating the specification.

Future Work

While the current toolkit is optimized for Vega-Lite, the structured JSON format is designed for easy translation into other libraries like ECharts or D3.js. Future developments will focus on expanding these language-specific converters and exploring automated annotation. Because the grammar understands "intent," future AI-driven tools could potentially use ChartMark to automatically generate relevant insights based on natural language queries, such as "Show me where the outliers are."

Summary updated

BibTeX
@misc{chen2025chartmark,
  author = {Yiyu Chen and Yifan Wu and Shuyu Shen and Yupeng Xie and Leixian Shen and Hui Xiong and Yuyu Luo},
  title = {{ChartMark: A Structured Grammar for Chart Annotation}},
  year = {2025},
  eprint = {2507.21810},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.21810},
}

Loading related content...

Figure