AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.

class anychart.core.ui.CrosshairLabel Improve this Doc

CrosshairLabel class.

Methods Overview

Specific settings
axisIndex()Axis index.
format()Text formatter function.
Advanced Text Settings
adjustFontSize()Adjust font settings.
maxFontSize()Maximum font size setting.
minFontSize()Minimum font size setting.
Coloring
background()Background settings.
Size and Position
anchor()Anchor settings.
height()Height settings.
offsetX()Offset by X.
offsetY()Offset by Y.
padding()Padding settings.
width()Width 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 - Label anchor settings.
Setter for the crosshair label anchor settings.

Params:

NameTypeDefaultDescription
valueanychart.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
valuestring | Object | null | boolean
true
Value 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 labels format function.
Learn more about using format() method.

Params:

NameTypeDescription
functionfunctionFunction to format label text.

Returns:

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

height

Getter for the crosshair label height.

Returns:

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

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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

maxFontSize

Getter for the font size for adjust text to.

Returns:

number - Current value.
Setter for the font size for adjust text to.

Params:

NameTypeDefaultDescription
valuenumber | string
72
Value 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
valuenumber | string
8
Value 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
valuenumber | string
0
Value 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
valuenumber | string
0
Value 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
valueArray.<(number|string)> | Object
{top: 5, right: 10, bottom: 5, left: 10}
Value 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);

width

Getter for the crosshair label width.

Returns:

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

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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