AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.4.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

class anychart.core.Text Improve this Doc

Extends: anychart.core.VisualBase

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

Methods Overview

Miscellaneous
disablePointerEvents()Pointer events.
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.
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

disablePointerEvents

Pointer events.

Params:

NameTypeDescription
valuebooleanValue to set.

Returns:

anychart.core.Text | boolean - .

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:

NameTypeDefaultDescription
valuestring
'#000'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontColor('rgba(200, 0, 15, .5)');
someTextElement.fontColor('red');

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Decoration | string
anychart.graphics.vector.Text.Decoration.NONE
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontDecoration('blink');

fontFamily

Getter for the font family.

Returns:

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

Params:

NameTypeDefaultDescription
valuestring
'Arial'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontFamily('Tahoma');

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:

NameTypeDefaultDescription
valuenumber
1
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontOpacity(0.3);

fontSize

Getter for text font size.

Returns:

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

Params:

NameTypeDefaultDescription
valuestring | number
'16px'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontSize('18px');
someTextElement.fontSize(18);

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.FontStyle | string
anychart.graphics.vector.Text.FontStyle.NORMAL
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontStyle('italic');

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.FontVariant | string
anychart.graphics.vector.Text.FontVariant.NORMAL
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.FontVariant('small-caps');

fontWeight

Getter for the text font weight.

Returns:

string | number - The current font weight.

Params:

NameTypeDefaultDescription
valuestring | number
'normal'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.fontWeight(400);
someTextElement.fontWeight('bold');

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.HAlign | string
anychart.graphics.vector.Text.HAlign.START
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.hAlign('center');

letterSpacing

Getter for the text letter spacing.

Returns:

string | number - The current letter spacing.

Params:

NameTypeDefaultDescription
valuestring | number
'normal'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.letterSpacing('-4px');

lineHeight

Getter for the text line height.

Returns:

string | number - The current text line height.

Params:

NameTypeDefaultDescription
valuestring | number
'normal'
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.lineHeight(14);

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:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.selectable(true);

textDirection

Getter for the text direction.

Returns:

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

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Direction | string
anychart.graphics.vector.Text.Direction.LTR
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.textDirection('rtl');

textIndent

Getter for the text indent.

Returns:

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

Params:

NameTypeDefaultDescription
valuenumber
0
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.textIndent(0.3);

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextOverflow | string
anychart.graphics.vector.Text.TextOverflow.CLIP
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.textOverflow(anychart.graphics.vector.Text.TextOverflow.ELLIPSIS);

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:

NameTypeDescription
namestringSetting name.

Returns:

string | number | boolean | undefined - Value of the setting.
Example
someTextElement.textSettings('fontFamily');
Setter for text appearance settings.
Overrides current text settings by passed settings object.

Params:

NameTypeDescription
objectWithSettingsObjectSettings 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.core.Text - Self instance for method chaining.
Example
someTextElement.textSettings({'fontFamily': 'Tahoma', 'fontColor': 'red'});
Setter for the text appearance settings.
Overrides text setting Value by its Name.

Params:

NameTypeDescription
nameObjectSetting name.
valuestring | number | booleanSetting value.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.textSettings('fontFamily', 'Tahoma');

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextWrap | string
anychart.graphics.vector.Text.TextWrap.BY_LETTER
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.textWrap('noWrap');

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:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.useHtml(true);

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:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.VAlign | string
anychart.graphics.vector.Text.VAlign.TOP
Value to set.

Returns:

anychart.core.Text - Self instance for method chaining.
Example
someTextElement.vAlign('middle');