AnyChart
API Reference
Still have questions?
Contact support
Top

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

Extends: anychart.core.Text

Class for a 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.
useHtml()Text useHtml settings.
wordBreak()Word break mode.
wordWrap()Word-wrap mode.
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.
Interactivity
enabled()Element state (enabled or disabled).
selectable()Text selectable option.
Size and Position
anchor()Anchor settings.
height()Height settings.
measureWithText()Measures the text with the current labels 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 adjust font size.

Returns:

Object - 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 label anchor settings.

Returns:

anychart.enums.Anchor | string - Label anchor settings.
Setter for the label anchor settings.

Params:

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

Returns:

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

background

Getter for label background settings.

Returns:

anychart.core.ui.Background - Label background.
Setter for label background settings.

Params:

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

Returns:

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

disablePointerEvents

Getter for the pointer events.

Returns:

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

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

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

enabled

Getter for the element state.

Returns:

boolean - Element state.
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
enablednull | 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 - Font color.
Setter for the text font color.
https://www.w3schools.com/html/html_colors.asp

Params:

NameTypeDefaultDescription
colorstring
'#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 - Font decoration.
Setter for the text font decoration.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Decoration | string
'none'
Font decoration to set.

Returns:

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

fontFamily

Getter for the font family.

Returns:

string - Font family.
Setter for the font family.

Params:

NameTypeDefaultDescription
familystring
'Verdana', Helvetica, Arial, sans-serif
Font family to set.

Returns:

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

fontOpacity

Getter for the text font opacity.

Returns:

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

Params:

NameTypeDefaultDescription
opacitynumber
1
Value to set.

Returns:

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

fontSize

Getter for the text font size.

Returns:

string | number - Font size.
Setter for the text font size.

Params:

NameTypeDefaultDescription
sizestring | number
16
Font size 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 - Font style.
Setter for the text font style.

Params:

NameTypeDefaultDescription
styleanychart.graphics.vector.Text.FontStyle | string
'normal'
Font style 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 - Font variant.
Setter for the text font variant.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.FontVariant | string
'normal'
Font variant to set.

Returns:

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

fontWeight

Getter for the text font weight.

Returns:

string | number - Font weight.

Params:

NameTypeDefaultDescription
weightstring | number
'normal'
Font weight to set.

Returns:

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

getIndex

Returns label index.

Returns:

number - Label index.

hAlign

Getter for the text horizontal align.

Returns:

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

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.HAlign | string
'start'
Value to set.

Returns:

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

height

Getter for the label height.

Returns:

number | string | null - Label height.
Setter for the label height.

Params:

NameTypeDescription
heightnumber | stringLabel height to set.

Returns:

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

letterSpacing

Getter for the text letter spacing.

Returns:

string | number - Letter spacing.

Params:

NameTypeDefaultDescription
spacingstring | 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 - Text line height.

Params:

NameTypeDefaultDescription
heightstring | number
'normal'
Value to set.

Returns:

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

maxFontSize

Getter maximum font size settings for adjust text to.

Returns:

number - Returns the maximum font size setting.
Setter for maximum font size settings for adjust text to.

Params:

NameTypeDescription
sizenumber | stringMaximum font size to set.

Returns:

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

measureWithText

Measures the text with the current labels settings.

Params:

NameTypeDescription
textstringText to measure.

Returns:

anychart.math.Rect - Returns the labels bounds.

minFontSize

Getter for minimum font size settings for adjust text from.

Returns:

number - Font size setting.
Setter for minimum font size settings for adjust text from.

Params:

NameTypeDescription
sizenumber | stringMinimum font size to set.

Returns:

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

offsetX

Getter for label offsetX settings.

Returns:

number | string - Label offsetX settings.
Setter for label offsetX settings.

Params:

NameTypeDescription
offsetnumber | stringOffset by X to set.

Returns:

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

offsetY

Getter for label offsetY settings.

Returns:

number | string - Label offsetY settings.
Setter for label offsetY settings.

Params:

NameTypeDescription
offsetnumber | stringOffset by Y 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
paddingArray.<(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 values.

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 label position settings.

Returns:

string - Label position settings.
Setter for the label position settings.

Params:

NameTypeDescription
positionstringLabel position to set.

Returns:

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

positionFormatter

Getter for the position formatter.

Returns:

* - Position formatter.
Setter for the position formatter.

Params:

NameTypeDescription
formatter*Position formatter.

Returns:

* - Self instance for method chaining.

rotation

Getter for the rotate a label around an anchor.

Returns:

number - Rotation angle in degrees.
Setter for the rotate a label around an anchor.

Params:

NameTypeDefaultDescription
anglenumber
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 text selectable option.
Setter for the text selectable.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state 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 - Text direction.
Setter for the text direction.

Params:

NameTypeDefaultDescription
directionanychart.graphics.vector.Text.Direction | string
'ltr'
Text direction to set.

Returns:

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

textIndent

Getter for the text indent.

Returns:

number - Text indent.
Setter for the text indent.

Params:

NameTypeDefaultDescription
indentnumber
0
Text indent 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 - Text overflow settings.
See listing
var title = chart.title();
var textOverflow = title.textOverflow();
Setter for the text overflow settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextOverflow | string
""
Text overflow settings 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 settings.
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,
     'wordWrap': smth,
     'wordBreak': smth,
     'textOverflow': smth,
     'selectable': smth,
     'useHtml': smth
     'textShadow':smth
   }

Returns:

anychart.core.ui.LabelsFactory.Label - Self instance for method chaining.
Setter for the text appearance settings.

Params:

NameTypeDescription
namestringSetting name.
settingsstring | number | boolean | functionText settings.

Returns:

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

useHtml

Getter for the useHTML flag.

Returns:

boolean - Value of useHTML flag.
Setter for flag useHTML.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state 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 - Text vertical align.
Setter for the text vertical align.

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.VAlign | string
'top'
Value to set.

Returns:

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

width

Getter for the label width.

Returns:

number | string | null - Label width.
Setter for the label width.

Params:

NameTypeDescription
widthnumber | stringLabel width to set.

Returns:

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

wordBreak

Getter for the word-break mode.

Returns:

anychart.enums.WordBreak | string - Word-break mode.
Setter for the word-break mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordBreak | string
"normal"
Word-break mode to set.

Returns:

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

wordWrap

Getter for the word-wrap mode.

Returns:

anychart.enums.WordWrap | string - Word-wrap mode.
Setter for the word-wrap mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordWrap | string
'normal'
Word-wrap mode to set.

Returns:

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

zIndex

Getter for the Z-index of the element.

Returns:

number - Z-index.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
zIndexnumber
0
Value to set.

Returns:

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