Top
You are looking at an outdated 7.13.0 version of this document. Switch to the 7.13.1 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.
textFormatter()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 current adjust font settings.

Returns:

Object - The current adjust font size settings.

Try it:

Setter for the adjust font settings.

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.
byHeight boolean
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]);

Try it:

anchor

Getter for the current crosshair label anchor settings.

Returns:

anychart.enums.Anchor - The current label anchor settings.

Try it:

Setter for the crosshair label anchor settings.

Params:

Name Type Default Description
value anychart.enums.Anchor | string
null
Value to set.

Returns:

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

Try it:

axisIndex

Getter for the current axis index.

Returns:

number - The current axis index

Try it:

Setter for the axis index.

Params:

Name Type Default Description
value number
0
Axis index

Returns:

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

Try it:

background

Getter for the crosshair label background settings.

Returns:

anychart.core.ui.Background - Returns the background settings.

Try it:

Setter for crosshair label background settings.

Params:

Name Type Default Description
value string | Object | null | boolean
true
Value to set.

Returns:

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

height

Getter for the current crosshair label height.

Returns:

number string null - The current label width.

Try it:

Setter for the crosshair label height.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

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

Try it:

maxFontSize

Gets font size setting for adjust text to.

Returns:

number - Current value.

Try it:

Sets font size setting for adjust text to.

Params:

Name Type Default Description
value number | string
72
Value to set.

Returns:

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

Try it:

minFontSize

Gets the current minimum font size setting for adjust text from.

Returns:

number - Current value.

Try it:

Sets the minimum font size setting for adjust text from.

Params:

Name Type Default Description
value number | string
8
Value to set.

Returns:

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

Try it:

offsetX

Getter for the current crosshair label offsetX settings.

Returns:

number string - The current label offsetX value.

Try it:

Setter for the crosshair label offsetX settings.

Arrows show offsets layout.

Params:

Name Type Default Description
value number | string
0
Value to set.

Returns:

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

Try it:

offsetY

Getter for the current crosshair label offsetY settings.

Returns:

number string - Label offsetY value.

Try it:

Setter for the crosshair label offsetY settings. See illustration in anychart.core.ui.CrosshairLabel#offsetX.

Params:

Name Type Default Description
value number | string
0
Value to set.

Returns:

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

Try it:

padding

Getter for the current crosshair label padding.

Returns:

anychart.core.utils.Padding - Label padding.

Try it:

Setter for crosshair label padding in pixels by one value.

Params:

Name Type Default Description
value Array.<(number|string)> | Object
{top: 5, right: 10, bottom: 5, left: 10}
Value to set.

Returns:

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

Try it:

Setter for crosshair label padding in pixels.

Params:

Name Type Default Description
value1 string | number
5
Top or top-bottom space.
value2 string | number
10
Right or right-left space.
value3 string | number
5
Bottom space.
value4 string | 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);

Try it:

textFormatter

Getter for the current labels text formatter function.

Returns:

function - Labels text formatter function.

Try it:

Setter for the labels text formatter function.

Params:

Name Type Default Description
value function
function() {return this.value}
Function to format label text. Function that looks like function(){ // this.max - maximum scale value // this.min - minimum scale value // this.rawValue - raw scale value // this.scale - axis scale for the crosshair // this.value - scale value return textFormatterValue; // type Function }.

Returns:

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

Try it:

width

Getter for the current crosshair label width.

Returns:

number string null - The Current label width.

Try it:

Setter for the crosshair label width.

Params:

Name Type Default Description
value number | string | null
null
Value to set.

Returns:

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

Try it: