# tspan

The SVG tspan element defines a subtext within a text element or another tspan element. It allows for adjustment of the style and/or position of that subtext as needed.

Usually, this element is create with:

const tspan = parentElement.add('tspan')

It's possible create as a disconnected element with gySVG('tspan') and attach it to the SVG document with .attachTo().

More info: mdn (opens new window) | w3c (opens new window)

# .x()

tspan.x( _ )

Set the x coordinate of the starting point of the text baseline.

  • argument: {} _

  • returns: {gySVGObject} The original object

const x = element.x();

Get the x current value.

  • returns: {}

# .y()

tspan.y( _ )

Set the y coordinate of the starting point of the text baseline.

  • argument: {} _

  • returns: {gySVGObject} The original object

const y = element.y();

Get the y current value.

  • returns: {}

# .dx()

tspan.dx( _ )

Set shifts the text position horizontally from a previous text element.

  • argument: {} _

  • returns: {gySVGObject} The original object

const dx = element.dx();

Get the dx current value.

  • returns: {}

# .dy()

tspan.dy( _ )

Set shifts the text position vertically from a previous text element.

  • argument: {} _

  • returns: {gySVGObject} The original object

const dy = element.dy();

Get the dy current value.

  • returns: {}

# .rotate()

tspan.rotate( _ )

Set rotates orientation of each individual glyph. Can rotate glyphs individually.

  • argument: {} _

  • returns: {gySVGObject} The original object

const rotate = element.rotate();

Get the rotate current value.

  • returns: {}

# .lengthAdjust()

tspan.lengthAdjust( _ )

Set how the text is stretched or compressed to fit the width defined by the textLength attribute.

  • argument: {} _

  • returns: {gySVGObject} The original object

const lengthAdjust = element.lengthAdjust();

Get the lengthAdjust current value.

  • returns: {}

# .textLength()

tspan.textLength( _ )

Set a width that the text should be scaled to fit. Value type: length|percentage ; Default value: none; Animatable: yes

  • argument: {} _

  • returns: {gySVGObject} The original object

const textLength = element.textLength();

Get the textLength current value.