AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.standalones.LabelsFactory Improve this Doc

Extends: anychart.core.ui.LabelsFactory

The LabelsFactory class contains methods for configuring standalones labels factory.

Methods Overview

Specific settings
clip()Labels clip settings.
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 setting.
minFontSize()Minimum font size setting.
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.
offsetX()Offset by X.
offsetY()Offset by Y.
padding()Padding settings.
position()Position settings.
positionFormatter()Position formatter function.
rotation()Rotation settings.
width()Width settings.
zIndex()Z-index of the element.
Miscellaneous
add()Creates a new instance of anychart.core.ui.LabelsFactory.Label, saves it in the factory
clear()Clears an array of labels.
container()Container for the elements.
draw()Labels drawing.
measure()Measure labels and returns labels bounds.
measureWithTransform()Measures label in its coordinate system and returns bounds as an array of points in parent coordinate system.
parentBounds()Getter for the parent bounds.

Methods Description

add

Creates a new instance of anychart.core.ui.LabelsFactory.Label, saves it in the factory and returns it.

Params:

NameTypeDescription
formatProvider*Object that provides info for format function.
positionProvider*Object that provides info for positionFormatter function.
indexnumberLabel index.

Returns:

anychart.core.ui.LabelsFactory.Label - Returns new label instance.

adjustFontSize

Getter for the adjust font size.

Returns:

Object - Adjust font size 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.standalones.LabelsFactory - Self instance for method chaining.
Setter for the adjusting font size by one parameter.

Params:

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

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

anchor

Getter for the labels anchor settings.

Returns:

anychart.enums.Anchor | string - Labels anchor setting.
Setter for the labels anchor settings.

Params:

NameTypeDefaultDescription
anchoranychart.enums.Anchor | string
'center'
Labels anchor settings.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

background

Getter for the labels background settings.

Returns:

anychart.core.ui.Background - Labels background.
Setter for the labels background settings.

Params:

NameTypeDefaultDescription
settingsstring | Object | null | boolean
false
Background settings to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

clear

Clears an array of labels.

Params:

NameTypeDescription
indexnumberIf set, removes only the label that is in passed index.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

clip

Getter for labels clip settings.
Setter for labels clip settings. Clips visible part of labels by a rectangle or shape.

Params:

NameTypeDescription
clipSettingsanychart.graphics.vector.Shape | string | anychart.graphics.vector.Clip | anychart.math.RectLabels clip settings.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

container

Getter for the container.

Returns:

anychart.graphics.vector.Layer | anychart.graphics.vector.Stage - An instance of the class for method chaining.
Setter for the container.

Params:

NameTypeDescription
elementanychart.graphics.vector.Layer | anychart.graphics.vector.Stage | string | ElementThe value to set.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - Self instance for method chaining.

draw

Labels drawing.

Returns:

anychart.standalones.LabelsFactory - Returns itself for chaining.

enabled

Getter for the element state.

Returns:

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

Params:

NameTypeDefaultDescription
enablednull | boolean
true
Enabled state to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

fontColor

Getter for the text font color.

Returns:

string - Font color.
See listing
var fontColor = labels.fontColor();
Setter for the text font color.
https://www.w3schools.com/html/html_colors.asp

Params:

NameTypeDescription
colorstringFont color to set.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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
12
Font size to set.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - Self instance for method chaining.

fontWeight

Getter for the text font weight.

Returns:

string | number - Font weight.
See listing
var fontWeight = labels.fontWeight();

Params:

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

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

hAlign

Getter for the text horizontal align.

Returns:

anychart.graphics.vector.Text.HAlign | string - Text horizontal align.
See listing
var hAlign = labels.hAlign();
Setter for the text horizontal align.

Params:

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

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

height

Getter for labels height settings.

Returns:

number | string | null - Labels height.
Setter for labels height settings.

Params:

NameTypeDefaultDescription
heightnumber | string
null
Height value to set.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - Self instance for method chaining.

maxFontSize

Getter for maximum font size settings for adjust text to.

Returns:

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

Params:

NameTypeDefaultDescription
sizenumber | string
72
Maximum font size to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

measure

Measure labels and returns labels bounds.

Params:

NameTypeDescription
formatProviderOrLabel* | anychart.core.ui.LabelsFactory.LabelObject that provides info for format function.
positionProvider*Object that provides info for positionFormatter function.
settingsObjectSettings to set.
cacheIndexnumberIndex of the cash.

Returns:

anychart.math.Rect - Labels bounds.

measureWithTransform

Measures label in its coordinate system and returns bounds as an array of points in parent coordinate system.

Params:

NameTypeDescription
formatProviderOrLabel* | anychart.core.ui.LabelsFactory.LabelObject that provides info for format function.
positionProvider*Object that provides info for positionFormatter function.
settingsObjectSettings to set.
cacheIndexIndexnumberof the cash.

Returns:

Array.<number> - Label bounds.

minFontSize

Getter for minimum font size settings for adjust text from.

Returns:

number - Minimum font size settings.
Setter for the minimum font size settings for adjust text from.

Params:

NameTypeDefaultDescription
sizenumber | string
8
Minimum font size to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

offsetX

Getter for the labels offsetX settings.

Returns:

number | string - Labels offsetX value.
Setter for the labels offsetX settings.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Labels offsetX settings to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

offsetY

Getter for the labels offsetY settings.

Returns:

number | string - Labels offsetY value.
Setter for the labels offsetY settings.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Labels offsetY settings to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

padding

Setter for labels padding in pixels using a single value.

Params:

NameTypeDefaultDescription
paddingArray.<(number|string)> | Object | number | string
{top: 2, right: 4, bottom: 2, left: 4}
Space value, object or array.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.
Setter for labels padding settings in pixels using several values.

Params:

NameTypeDefaultDescription
value1string | number
2
Top or top-bottom space.
value2string | number
4
Right or right-left space.
value3string | number
2
Bottom space.
value4string | number
4
Left space.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

parentBounds

Getter for the parent bounds.
Bounds that would be used in case of percent size calculations. Expects pixel values only.

Returns:

anychart.math.Rect - The parent bounds of the element.
Setter for the parent bounds using single value.
Bounds that would be used in case of percent size calculations. Expects pixel values only.

Params:

NameTypeDescription
boundsanychart.math.Rect | Object | number | nullBounds to set.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.
Setter for the parent bounds using several values.
Bounds that would be used in case of percent size calculations. Expects pixel values only.

Params:

NameTypeDescription
leftnumberLeft space.
topnumberTop space.
widthnumberElement width.
heightnumberElement height.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

position

Getter for the labels position settings.

Returns:

string - Labels position settings.
Setter for the labels position settings.
The default value and the list of available values can be different depending on where the labels are used, e.g. with axes of different types or with different charts. Find more information in the detailed description.

Params:

NameTypeDefaultDescription
positionstring
N/A
Labels position settings.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

positionFormatter

Getter for the labels position formatter function.

Returns:

function - Labels position formatter function.
Setter for the labels position formatter function.

Params:

NameTypeDefaultDescription
formatterfunction
function() {return this['value'];}
Labels position formatter function.

Returns:

anychart.standalones.LabelsFactory - Self instance for method chaining.

rotation

Getter for the rotation angle around an anchor.

Returns:

number - Rotation angle in degrees.
Setter for the rotation angle around an anchor.

Params:

NameTypeDefaultDescription
anglenumber
0
Rotation angle in degrees.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - Self instance for method chaining.

width

Getter for labels width settings.

Returns:

number | string | null - Labels width.
Setter for labels width settings.

Params:

NameTypeDefaultDescription
widthnumber | string
null
Labels width to set.

Returns:

anychart.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - 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.standalones.LabelsFactory - Self instance for method chaining.