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

class anychart.graphics.vector.vml.Text Improve this Doc

Extends: anychart.graphics.vector.Text

A class for text formatting.
Processes plain text and HTML text.
Plain text is set using the setText method anychart.graphics.vector.Text#text. HTML text is set using the setHtml method anychart.graphics.vector.Text#htmlText. A text style is set using the setStyle method anychart.graphics.vector.Text#style.

Methods Overview

Coloring
color()Color setting.
Events
listen()Adds an event listener.
listenOnce()Adds an event listener that is removed automatically after the listener fired once.
removeAllListeners()Removes all listeners from this listenable.
unlisten()Removes an event listener which was added with listen() or listenOnce().
Interactive
drag()Dragging setting.
Interactivity
visible()Visibility flag
Size and Position
appendTransformationMatrix()Combines the current transformation with the given transformation matrix.
getAbsoluteBounds()Gets element bounds in absolute coordinates (root element coordinate system).
getAbsoluteHeight()Returns height within root bounds.
getAbsoluteWidth()Returns width within root bounds.
getAbsoluteX()Returns an absolute X (root element coordinate system).
getAbsoluteY()Returns an absolute Y (root element coordinate system).
getBounds()Returns the bounds.
getHeight()Returns the height.
getRotationAngle()Returns the current rotation angle in degrees.
getTransformationMatrix()Returns the current transformation matrix.
getWidth()Returns the width.
getX()Returns X in the coordinate system of the parent.
getY()Returns Y in the coordinate system of the parent.
height()Height setting.
rotate()Rotates a shape around the given rotation point.
rotateByAnchor()Rotates a shape around the given anchor.
scale()Scales a shape. Scaling center is set in the coordinate system of the parent.
scaleByAnchor()Scales a shape by anchor. Scaling center is set as an anchor.
setPosition()Sets top left corner of a shape (transformation taken into account) in the coordinate system of the parent.
setRotation()Rotates a shape around the given point.
setRotationByAnchor()Rotates a shape around the given anchor.
setTransformationMatrix()Sets the transformation matrix.
translate()Moves a shape taking an account the current transformation.
width()Width setting.
x()X coordinate setting.
y()Y coordinate setting.
zIndex()Z-index setting.
Miscellaneous
attr()Attribute setting
clip()Clipping setting.
cursor()Cursor type.
decoration()Text decoration setting.
desc()Description setting
direction()Text direction setting.
disablePointerEvents()Pointer events setting.
disableStrokeScaling()Vector effect property
dispose()Disposes element completely.
domElement()Returns DOM element if element is rendered.
fontFamily()Font family setting.
fontSize()Font size setting.
fontStyle()Font style setting.
fontVariant()Font variant setting.
fontWeight()Font weight setting.
getStage()Stage object (to which the given element is bound).
hAlign()Horizontal align setting.
hasParent()Whether parent element is set.
htmlText()HTML format.
id()Element identifier
letterSpacing()Letter spacing setting.
lineHeight()Line height setting.
opacity()Opacity setting.
parent()Parent layer.
remove()Current element removes itself from the parent layer.
selectable()Text selection setting.
style()Text style settings.
text()Text setting.
textIndent()Text indent setting.
textOverflow()Text overflow setting.
textWrap()Text wrap setting.
title()Title setting
vAlign()Vertical align setting.

Methods Description

appendTransformationMatrix

Combines the current transformation with the given transformation matrix.

Params:

NameTypeDescription
m00numberScale X.
m10numberShear Y.
m01numberShear X.
m11numberScale Y.
m02numberTranslate X.
m12numberTranslate Y.

Returns:

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

attr

Getter for the attribute.

Params:

NameTypeDescription
keystringName of attribute.

Returns:

* - Attribute value.
Setter for the attribute.

Params:

NameTypeDescription
keystringName of attribute.
value*Value of attribute.

Returns:

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

clip

Gets the current clipping rectangle.

Returns:

anychart.graphics.math.Rect - An instance of the class for method chaining.
Sets the clipping rectangle.

Params:

NameTypeDescription
valueanychart.graphics.math.Rect | stringClipping rectangle.

Returns:

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

color

Getter for the text color.

Returns:

string - The text color.
Setter for the text color.

Params:

NameTypeDefaultDescription
valuestring
"#000"
Text color.

Returns:

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

cursor

Getter for the current cursor type.

Returns:

anychart.graphics.vector.Cursor - Current cursor type.
Setter for the cursor type.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Cursor
null
Cursor type.

Returns:

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

decoration

Getter for the current text decoration.

Returns:

string - The current text decoration.
Setter for text decoration.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.Decoration | stringText decoration.

Returns:

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

desc

Getter for the element description value.

Returns:

string | null | undefined - The element description value.
Setter for the element description value.

Params:

NameTypeDescription
valuestring | nullValue to set.

Returns:

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

direction

Getter for the current text direction.

Returns:

string - The current text direction
Setter for text direction.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Direction | string
"ltr"
Text direction.

Returns:

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

disablePointerEvents

Gets the current value of the pointer events.

Returns:

boolean - Returns property value.
Disables the pointer events.

Params:

NameTypeDefaultDescription
valueboolean
false
Pointer events property value.

Returns:

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

disableStrokeScaling

Getter for the current element's vector effect property.

Returns:

boolean - The current vector effect property.
See listing
var element = stage.rect(10, 10, 100, 40);
element.disableStrokeScaling();
Setter for the element's vector effect property.
Learn more by link.

Params:

NameTypeDefaultDescription
valueboolean
false
Vector effect property to set.

Returns:

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

dispose

Disposes element completely. Removes it from the parent layer, sets links to null, removes it from DOM.

domElement

Returns DOM element if element is rendered.
In case of Stage in Suspended state or unbound element – null is returned.

Returns:

Element - DOM element.

drag

Returns the current state flag.

Returns:

boolean | anychart.graphics.math.Rect - Absolute element bounds or flag.
Turns off/on dragging (moving) of an element.

Params:

NameTypeDefaultDescription
valueboolean | anychart.graphics.math.Rect
false
Flag or a dragging area.

Returns:

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

fontFamily

Getter for the current font family of text.

Returns:

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

Params:

NameTypeDefaultDescription
valuestring
"Verdana"
Font family.

Returns:

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

fontSize

Getter for the current font size of text.

Returns:

string | number - The current font size.
Setter for font size of text.

Params:

NameTypeDefaultDescription
valuestring | number
"10px"
Font size.

Returns:

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

fontStyle

Getter for the current font style of text.

Returns:

string - The current font style.
Setter for font style of text.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.FontStyle | stringFont style.

Returns:

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

fontVariant

Getter for the current font variant of text.

Returns:

string - The current font variant
Setter for font variant of text.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.FontVariant | stringFont variant.

Returns:

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

fontWeight

Getter for the current font weight of text.

Returns:

string - The current font weight.
Setter for font weight of text.

Params:

NameTypeDescription
valuestring | numberFont weight.

Returns:

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

getAbsoluteBounds

Gets element bounds in absolute coordinates (root element coordinate system).

Returns:

anychart.graphics.math.Rect - Absolute element bounds.

getAbsoluteHeight

Returns height within root bounds.
See illustrations at anychart.graphics.vector.Element#getAbsoluteWidth

Returns:

number - Height.

getAbsoluteWidth

Returns width within root bounds.

Returns:

number - Width.

getAbsoluteX

Returns an absolute X (root element coordinate system).

Returns:

number - Absolute X.

getAbsoluteY

Returns an absolute Y (root element coordinate system).

Returns:

number - Absolute Y.

getBounds

Returns the bounds.

Returns:

anychart.graphics.math.Rect - Bounds.

getHeight

Returns the height.

Returns:

number - Height.

getRotationAngle

Returns the current rotation angle in degrees.

Returns:

number - Rotation angle.

getStage

Stage object (to which the given element is bound).

Returns:

anychart.graphics.vector.Stage - Stage object.

getTransformationMatrix

Returns the current transformation matrix.

Returns:

Array.<number> - Transformation matrix array.

getWidth

Returns the width.

Returns:

number - Width.

getX

Returns X in the coordinate system of the parent.

Returns:

number - X in the coordinate system of the parent.

getY

Returns Y in the coordinate system of the parent.

Returns:

number - Y in the coordinate system of the parent.

hAlign

Getter for the current horizontal align of text.

Returns:

string - The current horizontal align.
Setter for horizontal align of text.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.HAlign | string
"start"
Horizontal align.

Returns:

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

hasParent

Whether parent element is set.

Returns:

boolean - Whether parent element is set.

height

Gets the current 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 - The current height.
Sets a height.

Params:

NameTypeDescription
valuenumber | stringHeight.

Returns:

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

htmlText

Getter for the current HTML format.

Returns:

string - Current plain text.
Setter for the HTML format.

Params:

NameTypeDescription
valuestringText with HTML tags.

Returns:

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

id

Gets the current element identifier.

Returns:

string - Returns element identifier.
Sets the element identifier.

Params:

NameTypeDescription
valuestringCustom identifier.

Returns:

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

letterSpacing

Getter for the current letter spacing of text.

Returns:

string - The current letter spacing.
Setter for letter spacing of text.

Params:

NameTypeDescription
valuestring | numberLetter spacing.

Returns:

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

lineHeight

Getter for the current line height of text.

Returns:

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

Params:

NameTypeDescription
valuestring | numberLetter height.

Returns:

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

listen

Adds an event listener.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener that is removed automatically after the listener fired once.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

opacity

Getter for the current text opacity.

Returns:

number - The current text opacity.
Setter for text opacity.

Params:

NameTypeDescription
valuenumberText opacity.

Returns:

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

parent

Returns the parent layer.

Returns:

anychart.graphics.vector.Layer | anychart.graphics.vector.Stage - Instance of element current layer.
Adds element to the given layer.

Params:

NameTypeDescription
valueanychart.graphics.vector.Layer | anychart.graphics.vector.StageParent layer.

Returns:

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

remove

Current element removes itself from the parent layer.

Returns:

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

removeAllListeners

Removes all listeners from this listenable.

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

rotate

Rotates a shape around the given rotation point.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
cxnumberRotation point X.
cynumberRotation point Y.

Returns:

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

rotateByAnchor

Rotates a shape around the given anchor.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
anchoranychart.graphics.vector.Anchor | stringRotation anchor.

Returns:

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

scale

Scales a shape. Scaling center is set in the coordinate system of the parent.

Params:

NameTypeDescription
sxnumberX scaling factor.
synumberY scaling factor.
cxnumberScaling point X.
cynumberScaling point Y.

Returns:

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

scaleByAnchor

Scales a shape by anchor. Scaling center is set as an anchor.

Params:

NameTypeDescription
sxnumberX scaling factor.
synumberY scaling factor.
anchoranychart.graphics.vector.Anchor | stringScaling anchor point.

Returns:

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

selectable

Getter for the current text selectable property.

Returns:

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

Params:

NameTypeDefaultDescription
valueboolean
true
Text selectable property.

Returns:

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

setPosition

Sets top left corner of a shape (transformation taken into account) in the coordinate system of the parent.

Params:

NameTypeDescription
xnumberX coordinate.
ynumberY coordinate.

Returns:

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

setRotation

Rotates a shape around the given point.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
cxnumberRotation point X.
cynumberRotation point Y.

Returns:

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

setRotationByAnchor

Rotates a shape around the given anchor.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
anchoranychart.graphics.vector.Anchor | stringRotation anchor.

Returns:

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

setTransformationMatrix

Sets the transformation matrix.

Params:

NameTypeDescription
m00numberScale X.
m10numberShear Y.
m01numberShear X.
m11numberScale Y.
m02numberTranslate X.
m12numberTranslate Y.

Returns:

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

style

Getter for the current text style.

Returns:

anychart.graphics.vector.TextStyle - The current text style.
Setter for the text style.

Params:

NameTypeDescription
valueanychart.graphics.vector.TextStyleStyle.

Returns:

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

text

Getter for the current text.

Returns:

string - Current text.
Setter for the text.

Params:

NameTypeDescription
valuestringPlaint text.

Returns:

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

textIndent

Getter for the current text indent.

Returns:

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

Params:

NameTypeDescription
valuenumberText indent of text.

Returns:

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

textOverflow

Getter for the current font text overflow of text.

Returns:

string - The current text overflow.
Setter for the font text overflow of text.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.TextOverflow | stringText overflow.

Returns:

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

textWrap

Getter for the current text wrap of text.

Returns:

string - The current text wrap.
Setter for text wrap of text.
Note: Works only with AnyChart product

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextWrap | string
"noWrap"
Text wrap.

Returns:

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

title

Getter for the element title value.

Returns:

string | null | undefined - The element title value.
Setter for the element title value.

Params:

NameTypeDescription
valuestring | nullValue to set.

Returns:

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

translate

Moves a shape taking an account the current transformation.

Params:

NameTypeDescription
txnumberX movement amount.
tynumberY movement amount.

Returns:

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

unlisten

Removes an event listener which was added with listen() or listenOnce().

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

vAlign

Getter for the current vertical align of text.

Returns:

string - The current vertical align.
Setter for vertical align of text.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.VAlign | stringVertical align.

Returns:

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

visible

Gets the current visibility flag.

Returns:

boolean - Returns the current visibility flag.
Hides or shows an element.

Params:

NameTypeDefaultDescription
isVisibleboolean
true
Visibility flag.

Returns:

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

width

Gets the current 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 - The current width.
Sets a width.

Params:

NameTypeDescription
valuenumber | stringWidth.

Returns:

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

x

Getter for the current X coordinate of text.

Returns:

number - The current X coordinate.
Setter for X coordinate of text.

Params:

NameTypeDescription
valuenumberX coordinate.

Returns:

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

y

Getter for the current Y coordinate of text.

Returns:

number - The current Y coordinate.
Setter for Y coordinate of text.

Params:

NameTypeDescription
valuenumberY coordinate.

Returns:

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

zIndex

Gets the current element's zIndex.

Returns:

number - Z-index.
Sets the element's zIndex.

Params:

NameTypeDescription
valuenumberZ-index to set.

Returns:

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