Series and annotations
Compare groups on shared scales with attributes.series, then add reference marks with setAnnotations(). Both preserve source-feature selection and provenance: a series is an encoding, not a second collection.
Grouped bars, scatterplots, and bubbles
Set attributes.series to a property containing nonempty string keys. Scatter, bubble, and bar charts draw the groups with categorical colors and a legend. Filtering keeps each group's original color and each bar's series slot.
Grouped bars need exactly one finite, nonnegative value per (category, series) pair. Missing pairs leave empty slots; duplicate pairs raise an error. Aggregate repeated observations before creating the collection. The example reserves an empty East category with a manual domain.
For scatterplots use attributes: { axis: ['distance', 'fare'], series: 'dayType' }; for bubbles also provide the size field in attributes.axis[2].
Series constraints
Do not combine attributes.series with attributes.color or topK. In series mode, transforms are supported only by line charts using reduce-series. To override series colors, use a categorical style.colorMap; an explicit color domain must include every source series key, including filtered-out groups. Color-domain order controls colors, not bar-slot order.
Grouped line charts
Use attributes.series with transform: { preset: 'reduce-series' } to reduce each group's arrays independently and draw one path per group. All groups share the union of observed bucket keys in line-chart order. scales.x.domain can specify their exact order and reserve entirely absent buckets.
A missing bucket breaks the path and its linked highlight: it is neither a zero nor a selectable row. In this example the Proposal path has a gap in February. Click a point to select its series and bucket, or brush horizontally to select points across both series. The console shows the original feature indices and their series membership or coverage in shares.
Fixed reference marks
Scatter, bubble, bar, and line charts support chart.setAnnotations(list). Each annotation needs a unique, nonempty id; label and CSS color are optional.
| Type | Coordinates | Example |
|---|---|---|
line | Exactly one of x or y | { id: 'target', type: 'line', y: 100 } |
point | Both x and y | { id: 'place', type: 'point', x: 5, y: 100 } |
band | A two-value interval on one axis | { id: 'range', type: 'band', y: [80, 120] } |
Use numbers on numeric axes and raw, unformatted keys on category or bucket axes. For a grouped line's point callout, supply series and the raw x bucket key, without y: it follows the transformed point and defaults to the series color. A missing or out-of-window point remains installed but hidden.
Reference marks do not extend automatic domains, select data, or contribute to provenance. Out-of-view marks are hidden or clipped. Calling setAnnotations() replaces the complete list without redrawing the data; setAnnotations([]) clears it. An invalid replacement leaves the previous list installed.
Statistical references
Use 'min', 'max', or 'mean' instead of a numeric line or point coordinate. Scatter and bubble support both axes; bar and line support Y only. On categorical/bucket axes these strings remain literal keys. Band endpoints must be fixed coordinates.
scatter.setAnnotations([
{ id: 'average', type: 'line', y: 'mean', label: 'Mean fare' },
{ id: 'centroid', type: 'point', x: 'mean', y: 'mean' },
{ id: 'trend', type: 'line', fit: 'linear' },
])Statistics pool finite observations across series after filtering and transforms, before manual display windows. A single-axis statistic uses all finite values on that axis; a centroid or least-squares fit uses complete X/Y pairs only. The fitted line spans the observed X extent and is hidden with fewer than two pairs or no X variation. A line chart's mean uses transformed bucket values, not the original observations inside each bucket.
Explore linked studies
- Manhattan’s noise rhythms — grouped timelines and a linked location view.
- Two airports, one destination — grouped timelines, reference marks, a map, and duration distributions.
- Same route, different ride — shared-scale scatterplots, fitted lines, centroids, and linked hourly bars.
See Extending for the registered-chart hooks and PlotAnnotation for the complete annotation type.