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

class anychart.core.ui.LabelsFactory.Label Improve this Doc

Extends: anychart.core.Text

Class for creation of sets of similar labels and management of such sets. Any individual label can be changed after all labels are displayed.

Methods Overview

Specific settings
getIndex()Returns label index.
Advanced Text Settings
adjustFontSize()Adjusting settings.
fontVariant()Font variant settings.
letterSpacing()Text letter spacing settings.
textDirection()Text direction settings.
textIndent()Text indent settings.
textOverflow()Text overflow settings.
textWrap()Text wrap settings.
useHtml()Text useHtml settings.
Base Text Settings
fontColor()Font color settings.
fontDecoration()Font decoration settings.
fontFamily()Font family settings.
fontOpacity()Font opacity settings.
fontSize()Font size settings.
fontStyle()Font style settings.
fontWeight()Font weight settings.
hAlign()Text horizontal align settings.
lineHeight()Text line height settings.
maxFontSize()Maximum font size settings.
minFontSize()Minimum font size settings.
vAlign()Text vertical align settings.
Coloring
background()Background settings.
Events
disablePointerEvents()Pointer events settings.
listen()Adds an event listener.
listenOnce()Adds a single time event listener.
removeAllListeners()Removes all listeners.
unlisten()Removes the listener.
unlistenByKey()Removes the listener by the key.
Export
print()Prints all elements.
Interactivity
enabled()Element state (enabled or disabled).
selectable()Text selectable option.
Size and Position
anchor()Anchor settings.
height()Height settings.
offsetX()Offset by X.
offsetY()Offset by Y.
padding()Padding settings.
position()Position settings.
positionFormatter()Position formatter.
rotation()Rotation settings.
width()Width settings.
zIndex()Z-index of the element.
Text Settings
textSettings()Text settings.

Methods Description

adjustFontSize

Getter for the current adjust font size.

Returns:

Object - The current adjustFontSize settings.
Setter for the adjusting font size by two parameters width and height.

Params:

NameTypeDefaultDescription
adjustByWidthboolean
false
Enables adjusting by width. Is font needs to be adjusted by width.
adjustByHeightboolean
false
Enables adjusting by height. Is font needs to be adjusted by height.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.
Setter for the adjusting font size by one parameter.

Params:

NameTypeDefaultDescription
valueObject | Array.<boolean> | boolean
false
Enables adjusting by width and height. Adjusting flag, object or array.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

anchor

Getter for the current label anchor settings.

Returns:

anychart.enums.Anchor - The current label anchor settings.
Setter for the label anchor settings.

Params:

NameTypeDefaultDescription
valueanychart.enums.Anchor | string
'center'
Value to set.

Returns:

anychart.enums.Anchor - Self instance for method chaining.

background

Getter for the current label background settings.

Returns:

anychart.core.ui.Background - The current background.
Setter for the current label background settings.

Params:

NameTypeDescription
valuestring | Object | null | booleanBackground settings to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

disablePointerEvents

Getter for the current pointer events.

Returns:

boolean - Flag of the current state.
Setter for the pointer events.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

enabled

Getter for the current element state.

Returns:

boolean - The current element state.
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
valuenull | boolean
false
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"#7c868e"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"none"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

fontFamily

Getter for the current font family.

Returns:

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

Params:

NameTypeDefaultDescription
valuestring
"Verdana", Helvetica, Arial, sans-serif
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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.ui.LabelsFactory.Label - Self instance for method chaining.

fontSize

Getter for the current text font size.

Returns:

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

Params:

NameTypeDefaultDescription
valuestring | number
16
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"normal"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"normal"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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.ui.LabelsFactory.Label - Self instance for method chaining.

getIndex

Returns label index.

Returns:

number - The current label index.

hAlign

Getter for the text horizontal align.

Returns:

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

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.HAlign | string
"start"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

height

Getter for the current label height.

Returns:

number | string | null - The current label height.
Setter for the label height.

Params:

NameTypeDescription
valuenumber | string | nullHeight to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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.ui.LabelsFactory.Label - Self instance for method chaining.

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.ui.LabelsFactory.Label - Self instance for method chaining.

listen

Adds an event listener to an implementing object.

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method. Function that looks like function(event){ // event.actualTarget - actual event target // event.currentTarget - current event target // event.iterator - event iterator // event.originalEvent - original event // event.point - event point // event.pointIndex - event point index }.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

maxFontSize

Gets the current maximum font size setting for adjust text to.

Returns:

number - The current maximum font size setting.
Sets the maximum font size setting for adjust text to.

Params:

NameTypeDescription
valuenumber | stringMaximum font size to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

minFontSize

Gets the current minimum font size setting for adjust text from.

Returns:

number - The current font size setting.
Sets the minimum font size setting for adjust text from.

Params:

NameTypeDescription
valuenumber | stringMinimum font size to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

offsetX

Getter for the current label offsetX settings.

Returns:

number | string - The current label offsetX settings.
Setter for the label offsetX settings.

Params:

NameTypeDescription
valuenumber | stringValue to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

offsetY

Getter for the current label offsetY settings.

Returns:

number | string - The current label offsetY settings.
Setter for the label offsetY settings.

Params:

NameTypeDescription
valuenumber | stringValue to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

padding

Getter for the label padding.

Returns:

anychart.core.utils.Padding - Label padding.
Setter for label padding in pixels using a single value.

Params:

NameTypeDescription
valueArray.<(number|string)> | Object | number | stringSpace value, object or array.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.
Setter for label padding setting in pixels using a several value.

Params:

NameTypeDescription
value1string | numberTop or top-bottom space.
value2string | numberRight or right-left space.
value3string | numberBottom space.
value4string | numberLeft space.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

position

Getter for the current label position settings.

Returns:

string - The current label position settings.
Setter for the current label position settings.

Params:

NameTypeDescription
valuestringValue to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

positionFormatter

Gets the current position formatter.

Returns:

* - The current position formatter.
Sets the position formatter.

Params:

NameTypeDescription
value*Position formatter.

Returns:

* - Self instance for method chaining.

print

Prints all elements on related stage.

Params:

NameTypeDefaultDescription
paperSizeOrOptionsanychart.graphics.vector.PaperSize | Object
Paper size or object with options.
landscapeboolean
false
Flag of landscape.

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

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

Returns:

number - Number of listeners removed.

rotation

Getter for the current rotate a label around an anchor.

Returns:

number - The current rotation angle in degrees.
Setter for the rotate a label around an anchor.

Params:

NameTypeDefaultDescription
valuenumber
0
Rotation angle in degrees.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

selectable

Getter for the text selectable option.

Returns:

boolean - The current text selectable option.
Setter for the text selectable.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"ltr"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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.ui.LabelsFactory.Label - Self instance for method chaining.

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
""
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

textSettings

Getter for the full text appearance settings.

Returns:

Object - A copy of settings object.
Getter for all text appearance settings.

Params:

NameTypeDescription
namestringSetting name.

Returns:

string | number | boolean | undefined - Value of the setting.
Setter for text appearance settings.

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.ui.LabelsFactory.Label - Self instance for method chaining.
Setter for the text appearance settings.

Params:

NameTypeDescription
namestringSetting name.
valuestring | number | boolean | functionSettings value.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

textWrap

Getter for the text wrap settings.

Returns:

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

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextWrap | string
"byLetter"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

NameTypeDescription
keyObjectThe key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

useHtml

Getter for the useHTML flag.

Returns:

boolean - The current value of useHTML flag.
Setter for flag useHTML.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

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
"top"
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

width

Getter for the current label width.

Returns:

number | string | null - The current label width.
Setter for the label width.

Params:

NameTypeDescription
valuenumber | string | nullWidth to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
valuenumber
0
Value to set.

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.