AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.annotations.Label Improve this Doc

Extends: anychart.core.annotations.Base

Label annotation.

Methods Overview

Specific settings
getPlot()Returns the plot on which the annotation is drawn.
getType()Returns annotation type.
markers()Markers settings.
text()Label text.
Axes and Scales
xScale()X-scale settings
yScale()Y-scale settings
Charts
getChart()Returns the chart on which the annotation is drawn.
Coloring
background()Background settings.
Content Text Settings
adjustFontSize()Adjusting settings.
disablePointerEvents()Pointer events 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.
fontVariant()Font variant settings.
fontWeight()Font weight settings.
hAlign()Text horizontal align settings.
letterSpacing()Text letter spacing settings.
lineHeight()Line height settings.
maxFontSize()Maximum font size setting.
minFontSize()Minimum font size settings.
textDirection()Text direction settings.
textIndent()Text indent settings.
textOverflow()Text overflow settings.
useHtml()Text useHtml settings.
vAlign()Text vertical align settings.
wordBreak()Word break mode.
wordWrap()Word-wrap mode.
Interactivity
allowEdit()Interactivity settings.
enabled()Element state (enabled or disabled).
hovered()Hovered state settings.
normal()Normal state settings.
select()Selects current annotation.
selectable()Text selectable option.
selected()Selected state settings.
Size and Position
anchor()Anchor settings.
bottom()Bottom bound settings.
bounds()Bounds settings.
getPixelBounds()Returns pixel bounds.
height()Height settings.
hoverGap()Hover gap settings.
left()Left bound settings.
maxHeight()Maximum height.
maxWidth()Maximum width.
minHeight()Minimum height.
minWidth()Minimum width.
offsetX()Offset by X.
offsetY()Offset by Y.
padding()Padding settings.
right()Right bound settings.
top()Top bound settings.
valueAnchor()Value anchor settings
width()Width settings.
xAnchor()X anchor settings
zIndex()Z-index of the element.

Methods Description

adjustFontSize

Getter for the adjust font settings.

Returns:

Object - AdjustFontSize settings.
Setter for the adjust font settings.

Params:

NameTypeDefaultDescription
bothOrByWidthObject | Array.<boolean> | boolean
{width: false, height: false}
If only one param is set, its value goes for another too (see source code).
byHeightboolean
Is font needs to be adjusted by height.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.
Example
label.adjustFontSize(false);
// the same
label.adjustFontSize(false, false);
// the same
label.adjustFontSize([false, false]);

allowEdit

Getter for an interactivity in the annotation.

Returns:

boolean - Interactivity settings.
See listing.
var allowEdit = annotation.allowEdit();
Setter for an interactivity in the annotation.

Params:

NameTypeDescription
value*Whether to disable the interactivity in the annotation. If set to false, the interactivity is disabled in the annotation.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

anchor

Getter for anchor settings.

Returns:

anychart.enums.Anchor | string - Anchor value.
See listing
var anchor = annotation.anchor();
Setter for anchor settings.

Params:

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

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

background

Getter for the background.

Returns:

anychart.core.ui.Background - Background instance.
Setter for the background.

Params:

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

Returns:

anychart.core.annotations.Label - Returns the background or itself for method chaining.

bottom

Getter for element bottom bound settings.

Returns:

number | string | undefined - Element's bottom bound setting.
Setter for element bottom bound settings.

Params:

NameTypeDefaultDescription
bottomnumber | string | null
null
Bottom bound settings for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

bounds

Getter for element bounds settings.

Returns:

anychart.core.utils.Bounds - Bounds of the element.
Setter for bounds of the element using one parameter.

Params:

NameTypeDescription
boundsanychart.utils.RectObj | anychart.math.Rect | anychart.core.utils.BoundsBounds of element.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.
Setter for element bounds settings.

Params:

NameTypeDefaultDescription
xnumber | string
null
X-coordinate.
ynumber | string
null
Y-coordinate.
widthnumber | string
null
Width.
heightnumber | string
null
Height.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

disablePointerEvents

Getter for the pointer events settings.

Returns:

boolean - The pointer events settings.
See listing
var disablePointerEvents = annotation.disablePointerEvents();
Setter for the pointer events settings.

Params:

NameTypeDefaultDescription
enabledboolean
false
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

enabled

Getter for the element state (enabled or disabled).

Returns:

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

Params:

NameTypeDefaultDescription
enabledboolean
true
Enabled state to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.
Example.
if (!element.enabled())
   element.enabled(true);

fontColor

Getter for font color settings.

Returns:

string - Font color settings.
See listing
var fontColor = annotation.fontColor();
Setter for font color settings.

Params:

NameTypeDescription
colorstringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontDecoration

Getter for the text font decoration.

Returns:

anychart.graphics.vector.Text.Decoration | string - Font decoration.
See listing
var fontDecoration = annotation.fontDecoration();
Setter for the text font decoration.

Params:

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

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontFamily

Getter for the font family.

Returns:

string - Font family.
See listing
var fontFamily = annotation.fontFamily();
Setter for font family.

Params:

NameTypeDescription
fontFamilystringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontOpacity

Getter for the text font opacity.

Returns:

number - Font opacity.
See listing
var fontOpacity = annotation.fontOpacity();
Setter for the text font opacity.
Double value from 0 to 1.

Params:

NameTypeDescription
opacitynumberValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontSize

Getter for font size settings.

Returns:

number - Font size settings.
See listing
var fontSize = annotation.fontSize();
Setter for font size settings.

Params:

NameTypeDescription
sizenumber | stringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontStyle

Getter for font style settings.

Returns:

anychart.graphics.vector.Text.FontStyle - Font style settings.
See listing
var fontStyle = annotation.fontStyle();
Setter for font style settings.

Params:

NameTypeDescription
typestring | anychart.graphics.vector.Text.FontStyleValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontVariant

Getter for font variant settings.

Returns:

anychart.graphics.vector.Text.FontVariant - Font variant settings.
See listing
var fontVariant = annotation.fontVariant();
Setter for font variant settings.

Params:

NameTypeDescription
typestring | anychart.graphics.vector.Text.FontVariantValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

fontWeight

Getter for font weight settings.

Returns:

string | number - Font weight settings.
See listing
var fontWeight = annotation.fontWeight();
Setter for font weight settings.

Params:

NameTypeDescription
weightstring | numberValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

getChart

Returns the chart on which the annotation is drawn.

getPixelBounds

Returns pixel bounds of the element due to parent bounds and self bounds settings.

Returns:

anychart.math.Rect - Pixel bounds of the element.

getPlot

Returns the plot on which the annotation is drawn.

Returns:

anychart.core.stock.Plot - Stock plot.

getType

Returns annotation type.

Returns:

anychart.enums.AnnotationTypes | string - Annotation type

hAlign

Getter for text horizontal align settings.

Returns:

anychart.graphics.vector.Text.HAlign - Horizontal align settings.
See listing
var hAlign = annotation.hAlign();
Setter for the text horizontal align settings.

Params:

NameTypeDescription
typestring | anychart.graphics.vector.Text.HAlignValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

height

Getter for element height settings.

Returns:

number | string | undefined - Element's height setting.
Setter for element height setting.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Height settings for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

hoverGap

Getter for the hover gap.

Returns:

number - The hover gap value.
See listing.
var hoverGap = annotation.hoverGap();
Setter for the hover gap.
The contour size around annotation.

Params:

NameTypeDescription
value*Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

hovered

Getter for hovered state settings.

Returns:

anychart.core.StateSettings - Hovered state settings
Setter for hovered state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

left

Getter for element left bound settings.

Returns:

number | string | undefined - Element's left bound setting.
Setter for element left bound settings.

Params:

NameTypeDefaultDescription
leftnumber | string | null
null
Left bound setting for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

letterSpacing

Getter for letter spacing settings.

Returns:

number | string - Letter spacing settings.
See listing
var letterSpacing = annotation.letterSpacing();
Setter for letter spacing settings.

Params:

NameTypeDescription
spacingnumber | stringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

lineHeight

Getter for the text line height.

Returns:

string | number - Text line height.
See listing
var lineHeight = annotation.lineHeight();

Params:

NameTypeDescription
heightstring | numberValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

markers

Getter for data markers.

Returns:

anychart.core.ui.MarkersFactory - Markers instance.
Setter for data markers.

Params:

NameTypeDefaultDescription
settingsObject | boolean | null | string
false
Data markers settings.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

maxFontSize

Getter for the font size for adjust text to.

Returns:

number - Maximum font size.
Setter for the font size for adjust text to.

Params:

NameTypeDescription
sizenumber | stringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

maxHeight

Getter for the maximum height.

Returns:

number | string | null - Element's maximum height.
Setter for the maximum height.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Maximum height to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

maxWidth

Getter for the maximum width.

Returns:

number | string | null - Element's maximum width.
Setter for the maximum width.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Maximum width to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

minFontSize

Getter for minimum font size settings for adjust text from.

Returns:

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

Params:

NameTypeDescription
sizenumber | stringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

minHeight

Getter for the minimum height.

Returns:

number | string | null - Element's minimum height.
Setter for the minimum height.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Minimum height to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

minWidth

Getter for the minimum width.

Returns:

number | string | null - Element's minimum width.
Setter for the minimum width.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Minimum width to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

normal

Getter for normal state settings.

Returns:

anychart.core.StateSettings - Normal state settings.
Setter for normal state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

offsetX

Getter for offset by X.

Returns:

number | string - Label offsetX value.
See listing
var offsetX = annotation.offsetX();
Setter for offset by X.

Arrows show offsets layout.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

offsetY

Getter for offset by Y.

Returns:

number | string - Label offsetY value.
See listing
var offsetY = annotation.offsetY();
Setter for offset by Y. See illustration in anychart.core.annotations.Label#offsetX.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

padding

Setter for paddings in pixels using a single value.

Params:

NameTypeDefaultDescription
paddingnull | Array.<(number|string)> | Object
5
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.
Examples for paddings
// all paddings 15px
label.padding(15);
// all paddings 15px
label.padding('15px');
// top and bottom 5px ,right and left 15px
label.padding(anychart.utils.padding(5,15));
Setter for paddings in pixels using several numbers.

Params:

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

Returns:

anychart.core.annotations.Label - Self instance for method chaining.
Examples for paddings
// 1) top and bottom 10px, left and right 15px
label.padding(10, '15px');
// 2) top 10px, left and right 15px, bottom 5px
label.padding(10, '15px', 5);
// 3) top 10px, right 15px, bottom 5px, left 12px
label.padding(10, '15px', '5px', 12);
Getter for element right bound settings.

Returns:

number | string | undefined - Element's right bound setting.
Setter for element right bound setting.

Params:

NameTypeDefaultDescription
rightnumber | string | null
null
Right bound setting for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

select

Selects current annotation.

selectable

Getter for the text selectable option.

Returns:

boolean - Text selectable option.
See listing
var selectable = annotation.selectable();
Setter for the text selectable.

Params:

NameTypeDefaultDescription
enabledboolean
false
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

selected

Getter for selected state settings.

Returns:

anychart.core.StateSettings - Selected state settings
Setter for selected state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

text

Getter for the text content for a label.

Returns:

string - Text content of a label.
See listing
var text = annotation.text();
Setter for text content for a label.

Params:

NameTypeDescription
textstringValue to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

textDirection

Getter for the text direction.

Returns:

anychart.graphics.vector.Text.Direction | string - Text direction.
See listing
var textDirection = annotation.textDirection();
Setter for the text direction.

Params:

NameTypeDefaultDescription
typeanychart.graphics.vector.Text.Direction | string
'ltr'
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

textIndent

Getter for the text indent.

Returns:

number - Text indent.
See listing
var textIndent = annotation.textIndent();
Setter for the text indent.

Params:

NameTypeDescription
indentnumberValue to set.

Returns:

anychart.core.annotations.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 textOverflow = annotation.textOverflow();
Setter for the text overflow settings.

Params:

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

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

top

Getter for element top bound settings.

Returns:

number | string | undefined - Element's top bound setting.
Setter for element top bound settings.

Params:

NameTypeDefaultDescription
topnumber | string | null
null
Top bound setting for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

useHtml

Getter for the useHTML flag.

Returns:

boolean - Value of useHTML flag.
See listing
var useHtml = annotation.useHtml();
Setter for the useHTML flag.

Params:

NameTypeDefaultDescription
enabledboolean
false
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

vAlign

Getter for the text vertical align.

Returns:

anychart.graphics.vector.Text.VAlign | string - Text vertical align.
See listing
var vAlign = annotation.vAlign();
Setter for the text vertical align.

Params:

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

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

valueAnchor

Getter for the value anchor.

Returns:

* - The value anchor.
See listing.
var valueAnchor = annotation.valueAnchor();
Setter for the value anchor.

Params:

NameTypeDescription
value*Value anchor to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

width

Getter for element width settings.

Returns:

number | string | undefined - Element's width setting.
Setter for element width setting.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Width settings for the element.

Returns:

anychart.core.annotations.Label - Returns self for method chaining.

wordBreak

Getter for the word-break mode.

Returns:

anychart.enums.WordBreak | string - Word-break mode.
See listing.
var wordBreak = annotation.wordBreak();
Setter for the word-break mode.

Params:

NameTypeDefaultDescription
typeanychart.enums.WordBreak | string
'normal'
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

wordWrap

Getter for the word-wrap mode.

Returns:

anychart.enums.WordWrap | string - Word-wrap mode.
See listing.
var wordWrap = annotation.wordWrap();
Setter for the word-wrap mode.

Params:

NameTypeDefaultDescription
typeanychart.enums.WordWrap | string
'normal'
Value to set.

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

xAnchor

Getter for the X anchor.

Returns:

* - The X anchor.
See listing.
var xAnchor = annotation.xAnchor();
Setter for the X anchor.

Params:

NameTypeDescription
value*X anchor to set.

Returns:

anychart.core.annotations.Line - Self instance for method chaining.

xScale

Setter for the X-scale.

Params:

NameTypeDefaultDescription
settingsanychart.scales.Base | anychart.scales.StockScatterDateTime | Object | anychart.enums.ScaleTypes | string
anychart.scales.Linear
Value to set

Returns:

anychart.core.annotations.Label - Self instance for method chaining.

yScale

Getter for the Y-scale.

Returns:

anychart.scales.Base - Default scale value.
Setter for the Y-scale.

Params:

NameTypeDefaultDescription
settingsanychart.scales.Base | Object | anychart.enums.ScaleTypes | string
anychart.scales.Linear
Y-scale to set.

Returns:

anychart.core.annotations.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.annotations.Label - Self instance for method chaining.