Skip to content

DataLabelOptions

Defined in: map/base-engine.ts:141

Engine-owned text labels for plot() / geoMap() (#223) — the data-driven analogue of network.labels(). You supply the data and d3-style accessors; the engine measures each label’s text once (no magic-number metrics), places + culls collisions on every pan/zoom (the shared LabelLayer machinery), and routes to the active backend — an HTML overlay on WebGL, native <text>/fillText on SVG/Canvas so labels survive toSVG()/toPNG() export. Styling mirrors network.labels(): a built-in default look, an inline style override, or a full-CSS className. Plain labels are vertically centred on the anchor (offset sits them beside the glyph); set rotationOf for the oriented (rotated) model.

D = unknown

anchorOf: (d, i) => [number, number] | null | undefined

Defined in: map/base-engine.ts:146

The label’s REFERENCE (world / pre-transform) anchor [x, y]; null/undefined skips it. For geoMap this is a projected point (e.g. projection(feature.geometry.coordinates)).

D

number

[number, number] | null | undefined


optional className?: string

Defined in: map/base-engine.ts:167

Advanced overlay styling: a CSS class that SKIPS the built-in default so the class’s CSS has full control (combine with style for inline overrides).


optional color?: string

Defined in: map/base-engine.ts:172

Fill colour for backend-native text. Defaults to style’s colour, then the default.


optional font?: string

Defined in: map/base-engine.ts:170

Font for backend-native text (SVG/Canvas, incl. export). Defaults to style’s font, then the built-in default. Also the font used to MEASURE label boxes.


optional halo?: object

Defined in: map/base-engine.ts:175

Legibility halo stroked behind backend-native text. Defaults to the built-in white halo unless style sets textShadow: "none".

color: string

width: number


optional importanceOf?: (d, i) => number

Defined in: map/base-engine.ts:148

Importance for collision priority and, when max caps, ranking (higher wins). Default 0.

D

number

number


optional keepUpright?: boolean

Defined in: map/base-engine.ts:158

Oriented labels only: flip 180° to keep text upright (radial-tree readability flip).


labelOf: (d, i) => string | null | undefined

Defined in: map/base-engine.ts:143

The label text for a datum, or null/"" to skip it (no label for that datum).

D

number

string | null | undefined


optional max?: number

Defined in: map/base-engine.ts:160

Cap the number of shown labels to the top-k by importance (default: no cap — collision thins).


optional offset?: [number, number] | ((d, i) => [number, number])

Defined in: map/base-engine.ts:150

Constant screen-px offset [dx, dy] from the anchor, or a per-datum accessor. Default [0, 0].


optional rotationOf?: (d, i) => number

Defined in: map/base-engine.ts:153

Oriented labels: reading-direction angle (radians) per datum — switches to the rotated collision/render model (text runs along the axis, vertically centred on the anchor).

D

number

number


optional style?: LabelStyle

Defined in: map/base-engine.ts:164

Inline overlay CSS (camelCased property → value), merged over the built-in default label look (a dark 11px sans-serif with a white halo) — a partial override like { color: "#333" } keeps the rest. Applied once per element at creation, never per frame.


optional textAnchor?: TextAnchor

Defined in: map/base-engine.ts:156

Which way text runs from the anchor (default "start"). Also places a PLAIN label’s box — "middle" centres it on the anchor — with the CSS transform derived to match (#204).