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. |
| textShadow() | Text shadow 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
- [false, false] - don't adjust (adjust is off )
- [true, false] - adjust width
- [false, true] - adjust height
- [true, true] - adjust the first suitable value.
Returns:
Object - AdjustFontSize settings.Note: Works only when anychart.core.annotations.Label#width and anychart.core.annotations.Label#height are set.
Note: anychart.core.annotations.Label#fontSize does not work when adjusting is enabled.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| bothOrByWidth | Object | Array.<boolean> | boolean | {width: false, height: false} | If only one param is set, its value goes for another too (see source code). |
| byHeight | boolean | Is font needs to be adjusted by height. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.label.adjustFontSize(false); // the same label.adjustFontSize(false, false); // the same label.adjustFontSize([false, false]);
allowEdit
Returns:
boolean - Interactivity settings.var allowEdit = annotation.allowEdit();
Params:
| Name | Type | Description |
|---|---|---|
| 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.Try it:
anchor
Returns:
anychart.enums.Anchor | string - Anchor value.var anchor = annotation.anchor();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| anchor | anychart.enums.Anchor | string | 'center-top' | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
background
- null/boolean - disable or enable label background.
- string - sets label background color value.
- object - sets label background settings.
Params:
| Name | Type | Description |
|---|---|---|
| settings | string | Object | null | boolean | Background object to set. |
Returns:
anychart.core.annotations.Label - Returns the background or itself for method chaining.bottom
Returns:
number | string | undefined - Element's bottom bound setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| bottom | number | string | null | null | Bottom bound settings for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
bounds
Returns:
anychart.core.utils.Bounds - Bounds of the element.Params:
| Name | Type | Description |
|---|---|---|
| bounds | anychart.utils.RectObj | anychart.math.Rect | anychart.core.utils.Bounds | Bounds of element. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| x | number | string | null | X-coordinate. |
| y | number | string | null | Y-coordinate. |
| width | number | string | null | Width. |
| height | number | string | null | Height. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
disablePointerEvents
Returns:
boolean - The pointer events settings.var disablePointerEvents = annotation.disablePointerEvents();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.enabled
Returns:
boolean - Element state.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enabled state to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.if (!element.enabled()) element.enabled(true);
Try it:
fontColor
Returns:
string - Font color settings.var fontColor = annotation.fontColor();
Params:
| Name | Type | Description |
|---|---|---|
| color | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontDecoration
Returns:
anychart.graphics.vector.Text.Decoration | string - Font decoration.var fontDecoration = annotation.fontDecoration();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.graphics.vector.Text.Decoration | string | anychart.graphics.vector.Text.Decoration#NONE | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontFamily
Returns:
string - Font family.var fontFamily = annotation.fontFamily();
Params:
| Name | Type | Description |
|---|---|---|
| fontFamily | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontOpacity
Returns:
number - Font opacity.var fontOpacity = annotation.fontOpacity();
Double value from 0 to 1.
Params:
| Name | Type | Description |
|---|---|---|
| opacity | number | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontSize
Returns:
number - Font size settings.var fontSize = annotation.fontSize();
Params:
| Name | Type | Description |
|---|---|---|
| size | number | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontStyle
Returns:
anychart.graphics.vector.Text.FontStyle - Font style settings.var fontStyle = annotation.fontStyle();
Params:
| Name | Type | Description |
|---|---|---|
| type | string | anychart.graphics.vector.Text.FontStyle | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontVariant
Returns:
anychart.graphics.vector.Text.FontVariant - Font variant settings.var fontVariant = annotation.fontVariant();
Params:
| Name | Type | Description |
|---|---|---|
| type | string | anychart.graphics.vector.Text.FontVariant | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
fontWeight
Returns:
string | number - Font weight settings.var fontWeight = annotation.fontWeight();
Params:
| Name | Type | Description |
|---|---|---|
| weight | string | number | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
getChart
Returns:
anychart.core.SeparateChart - Chart.Try it:
getPixelBounds
Returns:
anychart.math.Rect - Pixel bounds of the element.getPlot
Returns:
anychart.core.stock.Plot - Stock plot.Try it:
getType
hAlign
Returns:
anychart.graphics.vector.Text.HAlign - Horizontal align settings.var hAlign = annotation.hAlign();
Params:
| Name | Type | Description |
|---|---|---|
| type | string | anychart.graphics.vector.Text.HAlign | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
height
Returns:
number | string | undefined - Element's height setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | string | null | null | Height settings for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
hoverGap
Returns:
number - The hover gap value.var hoverGap = annotation.hoverGap();
The contour size around annotation.
Params:
| Name | Type | Description |
|---|---|---|
| value | * | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
hovered
Returns:
anychart.core.StateSettings - Hovered state settingsTry it:
Params:
| Name | Type | Description |
|---|---|---|
| settings | Object | State settings to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
left
Returns:
number | string | undefined - Element's left bound setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| left | number | string | null | null | Left bound setting for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
letterSpacing
Returns:
number | string - Letter spacing settings.var letterSpacing = annotation.letterSpacing();
Params:
| Name | Type | Description |
|---|---|---|
| spacing | number | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
lineHeight
Returns:
string | number - Text line height.var lineHeight = annotation.lineHeight();
https://www.w3schools.com/cssref/pr_text_letter-spacing.asp
Params:
| Name | Type | Description |
|---|---|---|
| height | string | number | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
markers
- null/boolean - disable or enable annotation markers.
- object - sets annotation markers settings.
- string - sets annotation markers type.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | Object | boolean | null | string | false | Data markers settings. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.maxFontSize
Returns:
number - Maximum font size.Params:
| Name | Type | Description |
|---|---|---|
| size | number | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.maxHeight
Returns:
number | string | null - Element's maximum height.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | string | null | null | Maximum height to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
maxWidth
Returns:
number | string | null - Element's maximum width.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| width | number | string | null | null | Maximum width to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
minFontSize
Returns:
number - Minimum font size.Params:
| Name | Type | Description |
|---|---|---|
| size | number | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.minHeight
Returns:
number | string | null - Element's minimum height.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | string | null | null | Minimum height to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
minWidth
Returns:
number | string | null - Element's minimum width.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| width | number | string | null | null | Minimum width to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
normal
Returns:
anychart.core.StateSettings - Normal state settings.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| settings | Object | State settings to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
offsetX
Returns:
number | string - Label offsetX value.var offsetX = annotation.offsetX();

Arrows show offsets layout.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| offset | number | string | 0 | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
offsetY
Returns:
number | string - Label offsetY value.var offsetY = annotation.offsetY();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| offset | number | string | 0 | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
padding
Returns:
anychart.core.utils.Padding - Padding settings.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| padding | null | Array.<(number|string)> | Object | 5 | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.// 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));Try it:
Params:
| Name | Type | Description |
|---|---|---|
| value1 | string | number | Top or top-bottom space. |
| value2 | string | number | Right or right-left space. |
| value3 | string | number | Bottom space. |
| value4 | string | number | Left space. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.// 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);
Try it:
right
Returns:
number | string | undefined - Element's right bound setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| right | number | string | null | null | Right bound setting for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
select
Try it:
selectable
Returns:
boolean - Text selectable option.var selectable = annotation.selectable();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
selected
Returns:
anychart.core.StateSettings - Selected state settingsTry it:
Params:
| Name | Type | Description |
|---|---|---|
| settings | Object | State settings to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
text
Returns:
string - Text content of a label.var text = annotation.text();
Params:
| Name | Type | Description |
|---|---|---|
| text | string | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
textDirection
Returns:
anychart.graphics.vector.Text.Direction | string - Text direction.var textDirection = annotation.textDirection();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.graphics.vector.Text.Direction | string | 'ltr' | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
textIndent
Returns:
number - Text indent.var textIndent = annotation.textIndent();
Params:
| Name | Type | Description |
|---|---|---|
| indent | number | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
textOverflow
Returns:
anychart.graphics.vector.Text.TextOverflow | string - Text overflow settings.var textOverflow = annotation.textOverflow();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| value | anychart.graphics.vector.Text.TextOverflow | string | "" | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
textShadow
Returns:
string - String representation of text shadow.var textShadow = annotation.textShadow();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| textShadow | anychart.graphics.vector.TextShadow | string | 'none' | Text shadow to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
top
Returns:
number | string | undefined - Element's top bound setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| top | number | string | null | null | Top bound setting for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
useHtml
Returns:
boolean - Value of useHTML flag.var useHtml = annotation.useHtml();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
vAlign
Returns:
anychart.graphics.vector.Text.VAlign | string - Text vertical align.var vAlign = annotation.vAlign();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.graphics.vector.Text.VAlign | string | 'top' | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
valueAnchor
Returns:
* - The value anchor.var valueAnchor = annotation.valueAnchor();
Params:
| Name | Type | Description |
|---|---|---|
| value | * | Value anchor to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
width
Returns:
number | string | undefined - Element's width setting.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| width | number | string | null | null | Width settings for the element. |
Returns:
anychart.core.annotations.Label - Returns self for method chaining.Try it:
wordBreak
Returns:
anychart.enums.WordBreak | string - Word-break mode.var wordBreak = annotation.wordBreak();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.enums.WordBreak | string | 'normal' | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
wordWrap
Returns:
anychart.enums.WordWrap | string - Word-wrap mode.var wordWrap = annotation.wordWrap();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.enums.WordWrap | string | 'normal' | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
xAnchor
Params:
| Name | Type | Description |
|---|---|---|
| value | * | X anchor to set. |
Returns:
anychart.core.annotations.Line - Self instance for method chaining.Try it:
xScale
Returns:
anychart.scales.Ordinal | anychart.scales.Linear | anychart.scales.Logarithmic | anychart.scales.StockScatterDateTime - Default scale value.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | anychart.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.Try it:
yScale
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | anychart.scales.Base | Object | anychart.enums.ScaleTypes | string | anychart.scales.Linear | Y-scale to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
zIndex
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| zIndex | number | 0 | Value to set. |
Returns:
anychart.core.annotations.Label - Self instance for method chaining.Try it:
