interface RVG · Factories
RvgTextFactory
interface RvgTextFactory
Factory for creating text visual elements that can be positioned along polyline paths or anchored at specific points with customizable styling and orientation.
Methods
label
label(text: string, style: string): RvgAnchoredTextCreates an unpositioned text visual element that can be positioned later.
text- The text content to display.
style- The visual style to apply to the text.
Returns An anchored text visual instance.
label(text: string, oriented: boolean, angle: number, offset: number, autoFlip: boolean, style: string): RvgAnchoredTextCreates an unpositioned text visual element that can be positioned later.
Deprecated. Use the overload with RvgLabelOptions.
text- The text content to display.
oriented- Indicates whether the text should be oriented according to the anchor's direction.
angle- The rotation angle of the text in radians.
offset- The distance offset from the anchor point.
autoFlip- Indicates whether the text should automatically flip to maintain readability.
style- The visual style to apply to the text.
Returns An anchored text visual instance.
label(text: string, style: string, options: RvgLabelOptions): RvgAnchoredTextCreates a text visual element that is not positioned yet (at the origin), with options.
text- The text content to display.
style- The visual style to apply to the text.
options- Anchor, offset, flip, orientation and angle.
Returns An anchored text visual instance.
labelAlongArc
labelAlongArc(text: string, arc: Arc | ShapeLike, style: string, options?: RvgLabelOptions | null): RvgTextPathCreates a text visual element that follows an arc from its start to its end. By default the
label is centered on the arc and stays upright (flip: "auto").
text- The text content to display along the arc.
arc- The arc whose path the text follows.
style- The visual style to apply to the text.
optionsoptional- Position (
at,anchor), offset and flip.
Returns A text path visual instance.
labelAlongCircle
labelAlongCircle(text: string, circle: Circle | ShapeLike, style: string, options?: RvgLabelOptions | null): RvgTextPathCreates a text visual element that follows a circle, starting at its first defining point in
the circle's direction. By default the label is centered at at: 0.5 and stays upright
(flip: "auto").
text- The text content to display along the circle.
circle- The circle whose outline the text follows.
style- The visual style to apply to the text.
optionsoptional- Position (
at,anchor), offset and flip.
Returns A text path visual instance.
labelAlongPolygon
labelAlongPolygon(text: string, polygon: Polygon | ShapeLike, style: string, options?: RvgLabelOptions | null): RvgTextPathCreates a text visual element that follows the outline of a polygon, starting at its first
vertex. By default the label is centered at at: 0.5; it may run around corners.
text- The text content to display along the polygon.
polygon- The polygon whose outline the text follows.
style- The visual style to apply to the text.
optionsoptional- Position (
at,anchor), offset and flip.
Returns A text path visual instance.
labelAlongPolyline
labelAlongPolyline(text: string, polyline: Polyline | ShapeLike, offset: number, flip: boolean, style: string): RvgTextPathCreates a text visual element that follows a polyline path with full control over offset and flip orientation.
Deprecated. Use the overload with RvgLabelOptions.
text- The text content to display along the polyline path.
polyline- The polyline whose path the text should follow.
offset- The distance offset from the polyline path.
flip- Indicates whether the text should be flipped relative to the path direction.
style- The visual style to apply to the text.
Returns A text path visual instance.
labelAlongPolyline(text: string, polyline: Polyline | ShapeLike, style: string): RvgTextPathCreates a text visual element that follows a polyline path using default offset and orientation.
text- The text content to display along the polyline path.
polyline- The polyline whose path the text should follow.
style- The visual style to apply to the text.
Returns A text path visual instance.
labelAlongPolyline(text: string, polyline: Polyline | ShapeLike, style: string, options: RvgLabelOptions): RvgTextPathCreates a text visual element that follows a polyline, with options.
text- The text content to display along the polyline.
polyline- The polyline whose path the text follows.
style- The visual style to apply to the text.
options- Position (
at,anchor), offset and flip.
Returns A text path visual instance.
labelAt
labelAt(text: string, anchor: Point | VectorLike, oriented: boolean, angle: number, offset: number, autoFlip: boolean, style: string): RvgAnchoredTextCreates an anchored text visual element with explicit control over rotation angle, offset distance, orientation mode, and automatic flipping.
Deprecated. Use the overload with RvgLabelOptions.
text- The text content to display.
anchor- The point where the text should be anchored.
oriented- Indicates whether the text should be oriented according to the anchor's direction.
angle- The rotation angle of the text in radians.
offset- The distance offset from the anchor point.
autoFlip- Indicates whether the text should automatically flip to maintain readability.
style- The visual style to apply to the text.
Returns An anchored text visual instance.
labelAt(text: string, anchor: Point | VectorLike, style: string): RvgAnchoredTextCreates an anchored text visual element at a point using default orientation and offset settings.
Turns upright along the anchor's direction as in 1.0, around the anchor and with the anchor
of the CSS. For a flip that keeps the label's place (start and end swapped), pass options,
also empty ones: labelAt(text, anchor, style, {}).
text- The text content to display.
anchor- The point where the text should be anchored.
style- The visual style to apply to the text.
Returns An anchored text visual instance.
labelAt(text: string, anchor: Point | VectorLike, style: string, options: RvgLabelOptions): RvgAnchoredTextCreates a text visual element anchored at a point. With a pin as the anchor the text follows
the pin's direction (oriented, default true) and stays upright (flip: "auto").
text- The text content to display.
anchor- The point (or pin) where the text is anchored.
style- The visual style to apply to the text.
options- Anchor, offset, flip, orientation and angle.
Returns An anchored text visual instance.
measure
measure(text: string, style: string): RvgTextSizeMeasures a text in a style of this group, without a label: its width and how far its font box reaches above and below the anchor. A label with the same text and style that is not rotated has an extent of this size.
The style is resolved as for a label of this group: class names with the group's class prefix
and the classes of the enclosing groups apply, and @style … for inline CSS. When
VisQuillOptions.measureText is set, it does the measuring.
The text is measured once, when called; the result does not change afterwards. Before the
page's fonts have loaded, the text is measured in a fallback font and the size is wrong.
Measure again when they have loaded: call it in Reactive.do([graphic.ready], () => { if (graphic.ready.value) … }), which runs again when fonts load later. In a group that is not
mounted, the default font of the page is used.
Inside a reaction the result is always that of the text passed. A label's extent there
still holds the box from before the reaction.
text- The text to measure.
style- The style of the text, as for
label.
Returns The width, ascent and descent of the text.
