class RVG · Factories

RvgLabelOptions

Options for labels: label, labelAt and the labelAlong… functions of RvgTextFactory.

All fields are optional. offset means the same for every label: a positive offset moves the text to the left of the direction of the anchor or the shape, which is above the text when it reads from left to right. A flip only turns the text: the label keeps its place and its side.

Properties

anchoroptional

anchor?: "start" | "end" | "middle"

Which point of the text sits at the anchor (along a shape: at at). Default: "start" for label and labelAt if the CSS sets nothing else, "middle" along shapes. When given, it overrides the CSS text-anchor. Start and end refer to the direction of the anchor or the shape, so a flipped label keeps its place: with "start" the text still begins at the anchor and covers the same stretch, only its reading direction is turned.

angleoptional

angle?: number

labelAt: an additional rotation in radians (default 0).

atoptional

at?: number

Along a shape: where the label sits, as a ratio of the shape's length (the ratio of pointAt; a circle starts at its first defining point). Default: 0 for anchor: "start", 0.5 for "middle", 1 for "end". Ignored by label and labelAt.

flipoptional

flip?: boolean | "auto"

true turns the text by 180° (along a shape: it runs the other way), "auto" does so only where the text would otherwise be upside down, false never. Default: "auto" for labelAt and along circles and arcs, false along polylines and polygons. A flipped label stays where it was (see anchor) and on the same side (offset, side): the text is turned around its baseline. For a label that keeps exactly its box, center the text vertically (CSS dominant-baseline: central); with another baseline the turned text moves across by about its height.

offsetoptional

offset?: number

Distance from the anchor or the shape (default 0); positive is left of the direction of the anchor or the shape, i.e. above the text as long as it is not flipped. A flipped label stays on that side. With side: the distance to that side of the shape.

orientedoptional

oriented?: boolean

labelAt: the text follows the direction of the anchor, e.g. a pin (default true).

sideoptional

side?: "outside" | "inside"

Circles, arcs and polygons: the side of the shape the offset moves the label to, "outside" or "inside", whatever the winding of the shape and whether the label is flipped. Absent: the offset is left of the shape's direction. Ignored by label, labelAt and labelAlongPolyline.