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

class anychart.elements.Text Improve this Doc

Extends: anychart.VisualBase

This class is responsible of the text formatting, it processes the plain text and the text in HTML format.

Methods Overview

Miscellaneous
fontColor()Getter for the text font color.
fontDecoration()Getter for the text font decoration.
fontFamily()Getter for the font family.
fontOpacity()Getter for the text font opacity.
fontSize()Getter for text font size.
fontStyle()Getter for the text font style.
fontVariant()Getter for the text font variant.
fontWeight()Getter for the text font weight.
hAlign()Getter for the text horizontal align.
hoverable()Pointer events.
letterSpacing()Getter for the text letter spacing.
lineHeight()Getter for the text line height.
selectable()Getter for the text selectable option.
textDirection()Getter for the text direction.
textIndent()Getter for the text indent.
textOverflow()Getter for the text overflow settings.
textSettings()Getter for the full text appearance settings.
textWrap()Getter for the text wrap settings.
useHtml()Getter for the useHTML flag.
vAlign()Getter for the text vertical align.

Methods Description

fontColor

Getter for the text font color.

Returns:

string - The current font color.
Setter for the text font color.
https://www.w3schools.com/html/html_colors.asp

Params:

Name Type Default Description
value string
'#000'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontDecoration

Getter for the text font decoration.

Returns:

anychart.graphics.vector.Text.Decoration string - The current font decoration.
Setter for the text font decoration.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.Decoration | string
anychart.graphics.vector.Text.Decoration.NONE
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontFamily

Getter for the font family.

Returns:

string - The current font family.
Setter for font family.

Params:

Name Type Default Description
value string
'Arial'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontOpacity

Getter for the text font opacity.

Returns:

number - The current font opacity.
Setter for the text font opacity.
Double value from 0 to 1.

Params:

Name Type Default Description
value number
1
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontSize

Getter for text font size.

Returns:

string number - Current font size.
Setter for text font size.

Params:

Name Type Default Description
value string | number
'16px'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontStyle

Getter for the text font style.

Returns:

anychart.graphics.vector.Text.FontStyle string - The current font style.
Setter for the text font style.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.FontStyle | string
anychart.graphics.vector.Text.FontStyle.NORMAL
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontVariant

Getter for the text font variant.

Returns:

anychart.graphics.vector.Text.FontVariant string - The current font variant.
Setter for the text font variant.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.FontVariant | string
anychart.graphics.vector.Text.FontVariant.NORMAL
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

fontWeight

Getter for the text font weight.

Returns:

string number - The current font weight.
Setter for the text font weight.
https://www.w3schools.com/cssref/pr_font_weight.asp

Params:

Name Type Default Description
value string | number
'normal'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

hAlign

Getter for the text horizontal align.

Returns:

anychart.graphics.vector.Text.HAlign string - Th current text horizontal align.
Setter for the text horizontal align.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.HAlign | string
anychart.graphics.vector.Text.HAlign.START
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

hoverable

Pointer events.

Params:

Name Type Description
value boolean .

Returns:

anychart.elements.Text boolean - .

letterSpacing

Getter for the text letter spacing.

Returns:

string number - The current letter spacing.

Params:

Name Type Default Description
value string | number
'normal'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

lineHeight

Getter for the text line height.

Returns:

string number - The current text line height.

Params:

Name Type Default Description
value string | number
'normal'
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

selectable

Getter for the text selectable option.

Returns:

boolean - The current text selectable option.
Setter for the text selectable.
This options defines whether the text can be selected. If set to false one can't select the text.

Params:

Name Type Default Description
value boolean
false
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

textDirection

Getter for the text direction.

Returns:

anychart.graphics.vector.Text.Direction string - Current text direction.
Setter for the text direction.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.Direction | string
anychart.graphics.vector.Text.Direction.LTR
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

textIndent

Getter for the text indent.

Returns:

number - The current text indent.
Setter for the text indent.

Params:

Name Type Default Description
value number
0
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

textOverflow

Getter for the text overflow settings.

Returns:

anychart.graphics.vector.Text.TextOverflow string - The current text overflow settings.
Setter for the text overflow settings.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.TextOverflow | string
anychart.graphics.vector.Text.TextOverflow.CLIP
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

textSettings

Getter for the full text appearance settings.

Returns:

Object - A copy of settings object.
Getter for all text appearance settings.
Note: Returns undefined if the name of the setting is wrong.

Params:

Name Type Description
name string Setting name.

Returns:

string number boolean undefined - Value of the setting.

Try it:

Setter for text appearance settings.
Overrides current text settings by passed settings object.

Params:

Name Type Description
objectWithSettings Object Settings object. Complete object looks like this: { 'fontSize': smth, 'fontFamily': smth, 'fontColor': smth, 'fontOpacity': smth, 'fontDecoration': smth, 'fontStyle': smth, 'fontVariant': smth, 'fontWeight': smth, 'letterSpacing': smth, 'textDirection': smth, 'lineHeight': smth, 'textIndent': smth, 'vAlign': smth, 'hAlign': smth, 'textWrap': smth, 'textOverflow': smth, 'selectable': smth, 'useHtml': smth }.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.
Setter for the text appearance settings.
Overrides text setting Value by its Name.

Params:

Name Type Description
name Object Setting name.
value string | number | boolean Setting value.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

textWrap

Getter for the text wrap settings.

Returns:

anychart.graphics.vector.Text.TextWrap string - Th current text wrap settings.
Setter for the text wrap settings.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.TextWrap | string
anychart.graphics.vector.Text.TextWrap.BY_LETTER
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

useHtml

Getter for the useHTML flag.

Returns:

boolean - The current value of useHTML flag.
Setter for flag useHTML.
This property defines whether HTML text should be parsed.

Params:

Name Type Default Description
value boolean
false
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it:

vAlign

Getter for the text vertical align.

Returns:

anychart.graphics.vector.Text.VAlign string - The current text vertical align.
Setter for the text vertical align.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.VAlign | string
anychart.graphics.vector.Text.VAlign.TOP
Value to set.

Returns:

anychart.elements.Text - An instance of anychart.elements.Text class for method chaining.

Try it: