Top
You are looking at an outdated 7.7.0 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.core.ui.Legend Improve this Doc

Extends: anychart.core.Text

Legend element.

Methods Overview

Specific settings
iconSize()Icon size.
inverted()Inverted settings.
items()Custom items.
itemsFormatter()Items formatter.
itemsSourceMode()Items source mode.
itemsTextFormatter()Items text formatter.
paginator()Paginator settings.
title()Title settings.
titleFormatter()Title formatter function.
titleSeparator()Title separator settings.
Coloring
background()Background settings.
Interactivity
hoverCursor()Cursor settings on hover state.
tooltip()Tooltip settings
Size and Position
align()Align settings.
getRemainingBounds()Getter for remain bounds after legend.
height()Height settings.
iconTextSpacing()Spacing between icon and text.
itemsLayout()Items layout settings.
itemsSpacing()Items spacing settings.
margin()Margin settings.
padding()Padding settings.
position()Position settings.
width()Width settings.

Methods Description

align

Getter for legend align settings.

Returns:

anychart.enums.Align string - Legend align.

Try it:

Setter for legend align settings.

Params:

Name Type Default Description
value anychart.enums.Align | string
"center"
Value to set.

Returns:

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

background

Getter for legend background.

Returns:

anychart.core.ui.Background - Current background settings.
Setter for legend background.

Params:

Name Type Default Description
value string | Object | null | boolean
true
Background setting.

Returns:

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

getRemainingBounds

Getter for remain bounds after legend.

Returns:

anychart.math.Rect - Bounds that remain after legend.

Try it:

height

Getter for legend height.

Returns:

number string null - Current height.

Try it:

Setter for legend height.

Params:

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

Returns:

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

Try it:

hoverCursor

Getter for hover cursor settings.

Returns:

anychart.enums.Cursor string - Hover cursor settings.

Try it:

Setter for hover cursor settings.

Params:

Name Type Default Description
value anychart.enums.Cursor | string
"pointer"
Hover cursor setting.

Returns:

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

Try it:

iconSize

Getter for icon size.

Returns:

number - Icon size setting.

Try it:

Setter for icon size.

Params:

Name Type Description
value number | string Icon size setting.

Returns:

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

Try it:

iconTextSpacing

Getter for spacing between icon and text in a legend item.

Returns:

number - Spacing settings.

Try it:

Setter for spacing between icon and text in a legend item.

Params:

Name Type Default Description
value string | number
5
Spacing settings.

Returns:

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

Try it:

inverted

Getter for inverted settings.

Returns:

boolean - Current inverted settings.

Try it:

Setter for inverted settings.

Params:

Name Type Default Description
value boolean
false
Whether item list should be inverted or not.

Returns:

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

Try it:

items

Getter for custom items.

Returns:

Array.<anychart.core.ui.Legend.LegendItemProvider> - Current custom item.
Setter for custom items.

Params:

Name Type Default Description
value Array.<anychart.core.ui.Legend.LegendItemProvider>
null
Items.

Returns:

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

Try it:

itemsFormatter

Getter for items formatter.

Returns:

function - Formatter function.
Setter for items formatter.

Params:

Name Type Default Description
value function
function (a){return a}
Formatter function.

Returns:

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

Try it:

itemsLayout

Getter for items layout.

Returns:

anychart.enums.Layout string - Current items layout.

Try it:

Setter for items layout.

Params:

Name Type Default Description
value string | anychart.enums.Layout
"horizontal"
Layout type for legend items.

Returns:

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

itemsSourceMode

Getter for items source mode.

Returns:

string anychart.enums.LegendItemsSourceMode - Items source mode.

Try it:

Setter for items source mode.

Params:

Name Type Default Description
value string | anychart.enums.LegendItemsSourceMode
"default"
Items source mode.

Returns:

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

Try it:

itemsSpacing

Getter for items spacing settings.

Returns:

string number - Items spacing settings.

Try it:

Setter for items spacing settings.

Params:

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

Returns:

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

Try it:

itemsTextFormatter

Getter for items text formatter.

Returns:

function - Items text formatter function.
Setter for items text formatter.

Params:

Name Type Description
value function Items text formatter function.

Returns:

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

Try it:

margin

Getter for the current margin setting.

Returns:

anychart.core.utils.Margin - Current legend margin.
Setter for legend margin in pixels using a single value.

Params:

Name Type Default Description
value Array.<(number|string)> | Object | number | string
{top: 4, right: 4, bottom: 4, left: 4}
Space value, object or array.

Returns:

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

Try it:

Setter for legend margin in pixels using a single simple values.

Params:

Name Type Default Description
value1 string | number
4
Top or top-bottom space.
value2 string | number
4
Right or right-left space.
value3 string | number
4
Bottom space.
value4 string | number
4
Left space.

Returns:

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

Try it:

padding

Getter for legend padding setting.

Returns:

anychart.core.utils.Padding - Current legend padding.
Setter for legend padding in pixels using a single value.

Params:

Name Type Default Description
value Array.<(number|string)> | Object | number | string
{top: 7, right: 7, bottom: 7, left: 7}
Space value, object or array.

Returns:

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

Try it:

Setter for legend padding setting in pixels using a several value.

Params:

Name Type Default Description
value1 string | number
7
Top or top-bottom space.
value2 string | number
7
Right or right-left space.
value3 string | number
7
Bottom space.
value4 string | number
7
Left space.

Returns:

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

Try it:

paginator

Getter for paginator setting.

Returns:

anychart.core.ui.Paginator - Current settings.
Setter for paginator setting.

Params:

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

Returns:

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

Try it:

position

Getter for legend position setting.

Returns:

anychart.enums.Orientation string - Legend position.

Try it:

Setter for legend position setting.

Params:

Name Type Default Description
value anychart.enums.Orientation | string
"bottom"
Legend position.

Returns:

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

title

Getter for legend title.

Returns:

anychart.core.ui.Title - Title settings.
Setter for legend title.

Params:

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

Returns:

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

titleFormatter

Gets the current legend title formatter function.

Returns:

function - Legend title formatter function.

Try it:

Sets the legend title formatter function. If set, formats title. Currently supported in Stock only.

Params:

Name Type Default Description
value null | function
null
Legend title formatter function.

Returns:

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

Try it:

titleSeparator

Getter for title separator setting.

Returns:

anychart.core.ui.Separator - Current settings.
Setter for title separator setting.

Params:

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

Returns:

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

tooltip

Getter for legend tooltip.

Returns:

anychart.core.ui.Tooltip - Tooltip instance.

Try it:

Setter for legend tooltip.

Params:

Name Type Default Description
value Object | boolean | null
true
Tooltip settings.

Returns:

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

width

Getter for legend width.

Returns:

number string null - Current width.

Try it:

Setter for legend width.

Params:

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

Returns:

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

Try it: