Published-release documentation · release compatibility

Stroke Dash Encoding

Aggregate cars line chart grouped by origin
Temporal aggregate paths with grouped series.

encodeStrokeDash(options)

Map a nominal or ordinal field to line-series or rule dash patterns, or apply one constant pattern to every series.

Contextual fragment. Use an ES module with the imports, data, and prepared resource state described in this section. Caller-provided receivers: program. Resolve these names from setup in this fragment or section; alternatives branch from the same base.

program.encodeStrokeDash({ field: "Origin" });

program.encodeStrokeDash({ value: "dotted" });
Option Type Default
field non-empty string; mutually exclusive with value —
value named style or direct dash pattern; mutually exclusive with field —
target line or rule mark ID current mark
fieldType "nominal" or "ordinal"; field mode only "nominal"
scale.id scale ID "strokeDash"
scale.type "ordinal" "ordinal"
scale.domain "auto" or category array "auto"
scale.range "auto" or named/direct pattern array "auto"
scale.unknown named style or direct pattern for a valid category outside the domain strict

Ordinal fields retain their ordered categorical meaning in semantic state. Automatic domains preserve first-appearance order; use scale.domain for a specific category order. Neither field type sorts the original rows or vertices.

For Cartesian line and rule marks, scale.unknown maps a valid category outside the domain without adding a legend entry or changing raw series identity. Missing or malformed categories still fail. Parallel, polar, aggregate and binned paths reject this fallback. Use editStrokeDashScale to replace it; explicit unknown: undefined removes it only if all consumers remain valid.

The automatic range contains ten reusable patterns. An explicit pattern is an empty array for a solid stroke or an even-length array of non-negative finite numbers that is not entirely zero. Named styles resolve as follows:

Style Concrete pattern
"solid" []
"dashed" [6, 4]
"dotted" [1, 3]
"dashdot" [6, 3, 1, 3]

Names remain in semantic scale state, while resolved scales and graphics store only numeric patterns.

Contextual fragment. Use an ES module with the imports, data, and prepared resource state described in this section. Caller-provided receivers: program. Resolve these names from setup in this fragment or section; alternatives branch from the same base.

program.encodeStrokeDash({
  field: "Origin",
  scale: { range: ["solid", "dashed", "dotted"] }
});

Calling the action again atomically replaces the earlier field or constant. The same field reuses its current scale when scale.id is omitted. A different field uses the default strokeDash scale unless an ID is explicit, while old named scales remain available as resources. Existing legend domains, symbols, and inferred titles update; custom legend settings remain unchanged.

Constant mode accepts no scale or field type. It creates no legend, removes the stroke-dash part of an existing combined legend, and removes a dash-only legend.

Without an explicit group, color and stroke dash must share one identity field. With encodeGroup, dash may use another field if it has one raw value per series. Compatible color and dash domains can be represented by one combined legend. Canvas changes explicitly rematerialize both styles.

See Scale options and Legends.

Series overview · Scale options · Legends

Documentation provenance

293 actions · sha256:e755591a2e5f5e2b494867583876e28020a478c5220b77bdc6ad469a6224891d