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

class anychart.elements.LabelsFactory Improve this Doc

Extends: anychart.elements.Text

Class for creation of sets of similar labels and management of such sets. Any individual label can be changed after all labels are displayed.

Methods Overview

Miscellaneous
add()Creates new instance of anychart.elements.LabelsFactory.Label, saves it in the factory
anchor()Gets or sets labels anchor settings.
background()Gets or sets the labels background settings.
clear()Clears an array of labels.
draw()Labels drawing.
enabled()Getter for the current element state.
height()LabelsFactory height settings.
measure()Measure labels using formatProvider, positionProvider and returns labels bounds.
measureWithTransform()Measures label in its coordinate system and returns bounds as an array of points in parent coordinate system.
offsetX()Gets or sets labels offsetX settings.
offsetY()Gets or sets labels offsetY settings.
padding()Labels padding.
position()Gets or sets labels position settings. These settings are processed by the factory handler (for example a series,
positionFormatter()Gets or sets labels position formatter function.
rotation()Sets rotation angle around an anchor.
textFormatter()Gets or sets labels text formatter function.
width()LabelsFactory width settings.

Methods Description

add

Creates new instance of anychart.elements.LabelsFactory.Label, saves it in the factory and returns it.

Params:

Name Type Description
formatProvider * Object that provides info for textFormatter function.
positionProvider * Object that provides info for positionFormatter function.
index number Label index.

Returns:

anychart.elements.LabelsFactory.Label - Returns new label instance.

anchor

Gets or sets labels anchor settings.

Params:

Name Type Description
value anychart.enums.Anchor | string Labels anchor settings.

Returns:

anychart.elements.LabelsFactory anychart.enums.Anchor - Labels anchor settings or itself for chaining call.

background

Gets or sets the labels background settings.

Params:

Name Type Description
value anychart.elements.Background | Object | null Background object to set.

Returns:

anychart.elements.LabelsFactory anychart.elements.Background - Returns the background or itself for chaining.

clear

Clears an array of labels.

Params:

Name Type Description
index number If set, removes only the label that is in passed index.

Returns:

anychart.elements.LabelsFactory - Returns itself for chaining.

draw

Labels drawing.

Returns:

anychart.elements.LabelsFactory - Returns itself for chaining.

enabled

Getter for the current element state. True, false and null states. True and false are self-explanatory. null state means that element is enabled, but if it depends on other entities (like, for example, labels() and hoverLabels() in series), then factory works in auto mode. For example, if series normal labels are enable, and hover labels are in null state, then upon hover hoverLabels become enabled because of normal. But if you disable normal labels – hoverLabels are disabled too.

Returns:

boolean - The current element state.
Setter for the element enabled state.

Params:

Name Type Description
value null | boolean Value to set.

Returns:

anychart.LabelsFactory - An instance of anychart.VisualBase class for method chaining.

Try it:

height

LabelsFactory height settings.

Params:

Name Type Description
value number | string | null Height value to set.

Returns:

anychart.elements.LabelsFactory number string null - LabelsFactory height or itself for chaining.

measure

Measure labels using formatProvider, positionProvider and returns labels bounds.

Params:

Name Type Description
formatProviderOrLabel * | anychart.elements.LabelsFactory.Label Object that provides info for textFormatter function.
positionProvider * Object that provides info for positionFormatter function.
settings Object .

Returns:

anychart.math.Rect - Labels bounds.

measureWithTransform

Measures label in its coordinate system and returns bounds as an array of points in parent coordinate system.

Params:

Name Type Description
formatProviderOrLabel * | anychart.elements.LabelsFactory.Label Object that provides info for textFormatter function.
positionProvider * Object that provides info for positionFormatter function.
settings Object .

Returns:

Array.<number> - Label bounds.

offsetX

Gets or sets labels offsetX settings.

Params:

Name Type Description
value number | string Labels offsetX settings to set.

Returns:

number string anychart.elements.LabelsFactory - Labels offsetX value or itself for chaining call.

offsetY

Gets or sets labels offsetY settings.

Params:

Name Type Description
value number | string Labels offsetY settings to set.

Returns:

number string anychart.elements.LabelsFactory - Labels offsetY value or itself for chaining call.

padding

Labels padding.

Params:

Name Type Description
spaceOrTopOrTopAndBottom string | number | anychart.utils.Space Space object or top or top and bottom space.
rightOrRightAndLeft string | number Right or right and left space.
bottom string | number Bottom space.
left string | number Left space.

Returns:

anychart.elements.LabelsFactory anychart.utils.Padding - Padding or LabelsFactory for chaining.

position

Gets or sets labels position settings. These settings are processed by the factory handler (for example a series, or an axis) and can have different meanings from handler to handler. Try using anychart.enums.Position values.

Params:

Name Type Description
value string Labels position settings.

Returns:

anychart.elements.LabelsFactory string - Labels position settings or itself for chaining call.

positionFormatter

Gets or sets labels position formatter function.

Params:

Name Type Description
value function Labels position formatter function.

Returns:

function anychart.elements.LabelsFactory - Labels position formatter function or Labels instance for chaining call.

rotation

Sets rotation angle around an anchor. (anychart.graphics.vector.Element).

Params:

Name Type Description
value number Rotation angle in degrees.

Returns:

number anychart.elements.LabelsFactory - Rotation angle in degrees or Itself for chaining call.

textFormatter

Gets or sets labels text formatter function.

Params:

Name Type Description
value function Labels text formatter function.

Returns:

function anychart.elements.LabelsFactory - Labels text formatter function or Labels instance for chaining call.

width

LabelsFactory width settings.

Params:

Name Type Description
value number | string | null Width value to set.

Returns:

anychart.elements.LabelsFactory number string null - LabelsFactory width or itself for chaining call.