Marks
Marks define the semantic form of a layer. Create a mark first, then connect it to data through position, grouping, and appearance encodings. The first mark of each type infers its ID and current dataset when those choices are unambiguous.
Choose a mark family
At a glance
| Family | Create | Edit | Initial graphic |
|---|---|---|---|
| Point | createPointMark |
editPointMark, jitterPoints, removeJitter |
Point collection |
| Line | createLineMark |
editLineMark |
Path collection |
| Area | createAreaMark |
editAreaMark |
Closed path collection |
| Arc | createArcMark |
editArcMark |
Closed sector path collection |
| Bar | createBarMark |
editBarMark |
Rect collection |
| Rule | createRuleMark |
Encoding actions | Line collection |
| Text | createTextMark |
editTextMark, layoutLabels, removeLabelLayout |
Text collection |
| Rect | createRectMark |
editRectMark |
Rect collection |
Use removeMark({ target? }) to remove one complete stable mark owner. It also
removes generated composite children, unreferenced generated datasets, owned
legends, and selection/highlight state. Source data and resources shared by
another mark remain:
const barsOnly = layeredProgram.removeMark({ target: "points" });
Generated children such as regression lines cannot be removed directly; select their stable owner instead.
Creation establishes semantic ownership but may leave an empty collection. Concrete graphics appear when the required encodings make the mark renderable. Later Canvas, scale, grouping, or appearance edits explicitly rematerialize those graphics.
Shared inference
datadefaults to the current dataset.- The first omitted mark ID uses the semantic role:
"point","line","area","arc","bar","rect","rule", or"text". - A second mark of the same type requires an explicit ID.
- A newly layered mark can inherit compatible data, coordinate, x, and y encodings from the current layer, or one unique source on the current dataset.
- A grain-preserving aggregate is inherited when both mark recipes support the same result. For example, a line added after mean bars inherits that mean.
- Bin, stack, offset, and appearance policies are not copied into a mark recipe that does not support the same final item grain.
- Only field-based positions compatible with the new mark and existing scale type are inherited. Incompatible channels remain unencoded.
- Passing
dataexplicitly starts independent mark assembly and disables layered position inheritance.