Top
You are looking at an outdated 7.2.0 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.graphics.vector.Text Improve this Doc

Extends: anychart.graphics.vector.Element

Text class.
Do not invoke constructor directly. Use anychart.graphics.vector.Stage#text or anychart.graphics.vector.Layer#text to create layer or stage bound text.
Use anychart.graphics.text to create unbound text.

Methods Overview

Miscellaneous
color()Getter for text color.
decoration()Getter for text decoration.
direction()Getter for text direction.
fontFamily()Getter for font family of text.
fontSize()Getter for font size of text.
fontStyle()Getter for font style of text.
fontVariant()Getter for font variant of text.
fontWeight()Getter for font weight of text.
hAlign()Getter for horizontal align of text.
height()Returns height.
htmlText()Set up text in HTML format. Incoming text is parsed HTML parser.
letterSpacing()Getter for letter spacing of text.
lineHeight()Getter for line height of text.
opacity()Getter for text opacity.
selectable()Getter for text selectable property.
style()Getter for style.
text()Get current text.
textIndent()Getter for text indent.
textOverflow()Getter for font text overflow of text.
textWrap()Getter for text wrap of text.
vAlign()Getter for vertical align of text.
width()Returns width.
x()Getter for X coordinate of text.
y()Getter for Y coordinate of text.

Methods Description

color

Getter for text color.

Returns:

string -
Setter for text color.

Params:

Name Type Description
value string Text color.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

decoration

Getter for text decoration.

Returns:

string -
Setter for text decoration.

Params:

Name Type Description
value anychart.graphics.vector.Text.Decoration | string Text decoration.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

direction

Getter for text direction.

Returns:

string -
Setter for text direction.

Params:

Name Type Description
value anychart.graphics.vector.Text.Direction | string Text direction.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

fontFamily

Getter for font family of text.

Returns:

string -
Setter for font family of text.

Params:

Name Type Description
value string Font family.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

fontSize

Getter for font size of text.

Returns:

string number -
Setter for font size of text.

Params:

Name Type Description
value string | number Font size.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

fontStyle

Getter for font style of text.

Returns:

string -
Setter for font style of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.FontStyle | string Font style.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

fontVariant

Getter for font variant of text.

Returns:

string -
Setter for font variant of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.FontVariant | string Font variant.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

fontWeight

Getter for font weight of text.

Returns:

string -
Setter for font weight of text.

Params:

Name Type Description
value string | number Font weight.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

hAlign

Getter for horizontal align of text.

Returns:

string -
Setter for horizontal align of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.HAlign | string Horizontal align.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

height

Returns height.
Note: it is not calculated automatically and has no default, and if it was not set using setter - NaN is returned.

Returns:

number string -
Sets height.

Params:

Name Type Description
value number | string Height.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

htmlText

Get current text.

Returns:

string - Current plain text.
Set up text in HTML format. Incoming text is parsed HTML parser. The tags that define style will taken into consideration and applied to the final result. HTML tags supported:
  • <br> (<br/>)
  • <b></b>, <strong></strong>
  • <i></i>, <em></em>
  • <span></span> (font-style, font-variant, font-family, font-size, font-weight, color, letter-spacing, text-decoration, opacity)

Params:

Name Type Description
value string Text with HTML tags.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

letterSpacing

Getter for letter spacing of text.

Returns:

string -
Setter for letter spacing of text.

Params:

Name Type Description
value string | number Letter spacing.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

lineHeight

Getter for line height of text.

Returns:

string -
Sets line height, either as ratio or in pixels.

Params:

Name Type Description
value string | number Letter height.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

opacity

Getter for text opacity.

Returns:

number -
Setter for text opacity.

Params:

Name Type Description
value number Text opacity.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

selectable

Getter for text selectable property.

Returns:

boolean -
Setter for text selectable property.
Defines whether text can be selected. If false - no selection.

Params:

Name Type Description
value boolean Text selectable property.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

style

Getter for style.
Sets style.

Params:

Name Type Description
value anychart.graphics.vector.TextStyle Style.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

text

Get current text.

Returns:

string - Current text.
Set up plain text. Text will be take as is. All symbols will be displaying in result.

Params:

Name Type Description
value string Plaint text.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

textIndent

Getter for text indent.

Returns:

number -
Setter for text indent.
The text-indent property specifies the indentation of the first line in a text-block.

Params:

Name Type Description
value number Text indent of text.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

textOverflow

Getter for font text overflow of text.

Returns:

string -
Setter for font text overflow of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.TextOverflow | string Text overflow.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

textWrap

Getter for text wrap of text.

Returns:

string -
Setter for text wrap of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.TextWrap | string Text wrap.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

vAlign

Getter for vertical align of text.

Returns:

string -
Setter for vertical align of text.

Params:

Name Type Description
value anychart.graphics.vector.Text.VAlign | string Vertical align.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

width

Returns width.
Note: it is not calculated automatically and has no default, and if it was not set using setter - NaN is returned.

Returns:

number string -
Sets width.

Params:

Name Type Description
value number | string Width.

Returns:

anychart.graphics.vector.Text - anychart.graphics.vector.Text instance for method chaining.

Try it:

x

Getter for X coordinate of text.

Returns:

number -
Setter for X coordinate of text.

Params:

Name Type Description
value number X coordinate.

Try it:

y

Getter for Y coordinate of text.

Returns:

number -
Setter for Y coordinate of text.

Params:

Name Type Description
value number Y coordinate.

Try it: