AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.ui.CrosshairLabel Improve this Doc

Extends: anychart.core.Text

The CrosshairLabel class contains methods for configuring the label of the crosshair.
Crosshair label is used in text and position settings, the coloring, interactivity states and other settings.

Methods Overview

Specific settings
axisIndex()Axis index.
format()Text formatter function.
Advanced Text Settings
adjustFontSize()Adjust font settings.
fontVariant()Font variant settings.
letterSpacing()Text letter spacing settings.
maxFontSize()Maximum font size setting.
minFontSize()Minimum font size setting.
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.
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()Label position.
rotation()Rotation settings.
width()Width settings.
zIndex()Z-index of the element.
Text Settings
textSettings()Text settings.

Methods Description

adjustFontSize

Getter for adjust font settings.

Returns:

Object - Adjust font size.
Setter for 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.
byHeightboolean
Is font needs to be adjusted by height.

Returns:

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

anchor

Getter for crosshair label anchor settings.

Returns:

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

Params:

NameTypeDefaultDescription
anchoranychart.enums.Anchor | string
null
Value to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

axisIndex

Getter for the axis index.

Returns:

number - Axis index
Setter for the axis index.

Params:

NameTypeDefaultDescription
valuenumber
0
Axis index

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

background

Getter for crosshair label background settings.

Returns:

anychart.core.ui.Background - Returns background settings.
Setter for crosshair label background settings.

Params:

NameTypeDefaultDescription
settingsstring | Object | null | boolean
true
Value to set.

Returns:

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

enabled

Getter for the label state (enabled or disabled).

Returns:

boolean - Element state.
See listing
var enabled = label.enabled();
Setter for the label enabled state.

Params:

NameTypeDefaultDescription
enabledboolean
true
Enabled state to set.

Returns:

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

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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - 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.CrosshairLabel - Self instance for method chaining.

format

Getter for labels format function.

Returns:

function - Labels format function.
Setter for the labels format.
Learn more about using the format() method.

Params:

NameTypeDescription
tokenstringString token to format content label text.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.
Setter for labels format using function.
Learn more about using format() method.

Params:

NameTypeDescription
functionfunctionFunction to format label text.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

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.CrosshairLabel - Self instance for method chaining.

height

Getter for the crosshair label height.

Returns:

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

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Value to set.

Returns:

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

maxFontSize

Getter for the maximum font size for adjust text to.

Returns:

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

Params:

NameTypeDefaultDescription
sizenumber | string
72
Maximum font size to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

minFontSize

Getter for the minimum font size for adjust text from.

Returns:

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

Params:

NameTypeDefaultDescription
sizenumber | string
8
Minimum font size to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

offsetX

Getter for crosshair label offsetX settings.

Returns:

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

Arrows show offsets layout.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Offset by X to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

offsetY

Getter for crosshair label offsetY settings.

Returns:

number | string - Label offsetY value.
Setter for crosshair label offsetY settings. See illustration in anychart.core.ui.CrosshairLabel#offsetX.

Params:

NameTypeDefaultDescription
offsetnumber | string
0
Offset by Y to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.

padding

Setter for crosshair label padding in pixels by one value.

Params:

NameTypeDefaultDescription
paddingArray.<(number|string)> | Object
{top: 5, right: 10, bottom: 5, left: 10}
Padding to set.

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.
Setter for crosshair label padding in pixels.

Params:

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

Returns:

anychart.core.ui.CrosshairLabel - Self instance for method chaining.
Example
// 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);

position

Getter for label position.

Returns:

anychart.enums.SidePosition | string - Label position.
Setter for label position.

Params:

NameTypeDefaultDescription
valueanychart.enums.Position | string
'center'
Position to set.

Returns:

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

Params:

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

Returns:

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

width

Getter for the crosshair label width.

Returns:

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

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Crosshair label width to set.

Returns:

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