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. |
| itemsFormat() | Items text formatter. |
| itemsFormatter() | Items formatter. |
| itemsSourceMode() | Items source mode. |
| paginator() | Paginator settings. |
| title() | Title settings. |
| titleFormat() | Title format function. |
| titleSeparator() | Title separator settings. |
| Advanced Text Settings | |
| fontVariant() | Font variant settings. |
| letterSpacing() | Text letter spacing settings. |
| 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. |
| textShadow() | Text shadow settings. |
| vAlign() | Text vertical align settings. |
| Coloring | |
| background() | Background settings. |
| Events | |
| disablePointerEvents() | Pointer events settings. |
| Interactivity | |
| drag() | Enable/disable drag for a legend. |
| enabled() | Element state (enabled or disabled). |
| hoverCursor() | Cursor settings in hover mode. |
| selectable() | Text selectable option. |
| tooltip() | Tooltip settings |
| Size and Position | |
| align() | Align settings. |
| getCurrentPosition() | Actual legend pixel bounds settings. |
| getPixelBounds() | Returns pixel bounds of the legend. |
| getRemainingBounds() | Getter for remain bounds after legend. |
| height() | Height settings. |
| iconTextSpacing() | Spacing between icon and text. |
| itemsHAlign() | Items layout horizontal align. |
| itemsLayout() | Items layout settings. |
| itemsSpacing() | Items spacing settings. |
| margin() | Margin settings. |
| maxHeight() | Maximum height. |
| maxWidth() | Maximum width. |
| padding() | Padding settings. |
| position() | Position settings. |
| positionMode() | Position mode settings. |
| width() | Width settings. |
| zIndex() | Z-index of the element. |
| Text Settings | |
| textSettings() | Text settings. |
Methods Description
align
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| align | anychart.enums.Align | string | 'center' | Align to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
background
Returns:
anychart.core.ui.Background - Background settings.var background = legend.background();
- null/boolean - disable or enable legend background.
- string - sets legend background color value.
- object - sets legend background settings.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | string | Object | null | boolean | true | Background settings. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.disablePointerEvents
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enabled state to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
drag
Returns:
boolean - The dragging value.var drag = legend.drag();
Params:
| Name | Type | Description |
|---|---|---|
| enabled | boolean | Allows dragging of the legend. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
enabled
Returns:
boolean - Element state.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enabled state to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.if (!element.enabled()) element.enabled(true);
Try it:
fontColor
https://www.w3schools.com/html/html_colors.asp
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| color | string | '#7c868e' | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontDecoration
Returns:
anychart.graphics.vector.Text.Decoration | string - Font decoration.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| value | anychart.graphics.vector.Text.Decoration | string | 'none' | Font decoration to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontFamily
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| family | string | 'Verdana', Helvetica, Arial, sans-serif | Font family to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontOpacity
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| opacity | number | 1 | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontSize
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| size | string | number | 12 | Font size to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontStyle
Returns:
anychart.graphics.vector.Text.FontStyle | string - Font style.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| style | anychart.graphics.vector.Text.FontStyle | string | 'normal' | Font style to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontVariant
Returns:
anychart.graphics.vector.Text.FontVariant | string - Font variant.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| value | anychart.graphics.vector.Text.FontVariant | string | 'normal' | Font variant to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
fontWeight
https://www.w3schools.com/cssref/pr_font_weight.asp
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| weight | string | number | 'normal' | Font weight to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
getCurrentPosition
Returns:
Object - Items position.Try it:
getPixelBounds
getRemainingBounds
Returns:
anychart.math.Rect - Bounds that remain after legend.Try it:
hAlign
Returns:
anychart.graphics.vector.Text.HAlign | string - Text horizontal align.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| align | anychart.graphics.vector.Text.HAlign | string | 'start' | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
height
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | string | null | null | Legend height to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
hoverCursor
Returns:
anychart.enums.Cursor | string - Hover cursor settings.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| cursorTypr | anychart.enums.Cursor | string | 'pointer' | Hover cursor setting. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
iconSize
Params:
| Name | Type | Description |
|---|---|---|
| size | number | string | Icon size setting. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
iconTextSpacing
Returns:
number - Spacing settings.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| spacing | string | number | 5 | Spacing settings. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
inverted
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Whether item list should be inverted or not. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
items
Returns:
Array.<anychart.core.ui.Legend.LegendItemProvider> - Custom item.var items = legend.items();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| itemsList | Array.<anychart.core.ui.Legend.LegendItemProvider> | null | Items array to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsFormat
Returns:
function - Items text formatter function.var itemsFormat = legend.itemsFormat();
Learn more about using itemsFormat() method.
Params:
| Name | Type | Description |
|---|---|---|
| format | function(value:Object):string | string | Items text formatter function. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsFormatter
Returns:
function(items:Array.<anychart.core.ui.Legend.LegendItemProvider>):Array.<anychart.core.ui.Legend.LegendItemProvider> - Formatter function.var itemsFormatter = legend.itemsFormatter();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| formatterFunction | function(items:Array.<anychart.core.ui.Legend.LegendItemProvider>):Array.<anychart.core.ui.Legend.LegendItemProvider> | function (a){return a} | Formatter function. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsHAlign
Returns:
anychart.enums.HAlign | string - Items horizontal align.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| hAlign | anychart.enums.HAlign | string | 'left' | Legend items horizontal align. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsLayout
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| layout | anychart.enums.LegendLayout | string | 'horizontal' | Layout type for legend items. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsSourceMode
Returns:
anychart.enums.LegendItemsSourceMode | string - Items source mode.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| mode | anychart.enums.LegendItemsSourceMode | string | 'default' | Items source mode. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
itemsSpacing
Returns:
string | number - Items spacing settings.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| spacing | string | number | 15 | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
letterSpacing
https://www.w3schools.com/cssref/pr_text_letter-spacing.asp
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| spacing | string | number | 'normal' | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
lineHeight
https://www.w3schools.com/cssref/pr_dim_line-height.asp
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | string | number | 'normal' | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
margin
Returns:
anychart.core.utils.Margin - Legend margin.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| margin | 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:
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:
maxHeight
Returns:
number | string | null - The maximum height.var maxHeight = legend.maxHeight();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | string | null | Maximum height to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
maxWidth
Returns:
number | string | null - The maximum width.var maxWidth = legend.maxWidth();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| width | number | string | null | null | Maximum width to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
padding
Returns:
anychart.core.utils.Padding - Legend padding.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| padding | 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:
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
Returns:
anychart.core.ui.Paginator - Paginator settings.var paginator = legend.paginator();
- null/boolean - disable or enable legend separator.
- object - sets separator settings.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | Object | boolean | null | true | Paginator settings to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
position
Returns:
anychart.enums.Orientation | string - Legend position.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| position | anychart.enums.Orientation | string | 'bottom' | Legend position to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| position | Object | Object with position coordinates like {x: 0, y: 0}. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
positionMode
Returns:
anychart.enums.LegendPositionMode | string - Legend position mode.var positionMode = legend.positionMode();
Params:
| Name | Type | Description |
|---|---|---|
| mode | anychart.enums.LegendPositionMode | string | Legend position mode. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
selectable
Returns:
boolean - The text selectable option.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enabled state to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
textDirection
Returns:
anychart.graphics.vector.Text.Direction | string - Text direction.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| direction | anychart.graphics.vector.Text.Direction | string | 'ltr' | Text direction to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
textIndent
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| indent | number | 0 | Text indent to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
textOverflow
Returns:
anychart.graphics.vector.Text.TextOverflow | string - Text overflow settings.var title = chart.title(); var textOverflow = title.textOverflow();
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| value | anychart.graphics.vector.Text.TextOverflow | string | "" | Text overflow settings to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
textSettings
Returns:
Object - A copy of settings object.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| name | string | Setting name. |
Returns:
string | number | boolean | undefined - Value of settings.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| objectWithSettings | Object | Settings 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.Legend - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| name | string | Setting name. |
| settings | string | number | boolean | function | Text settings. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
textShadow
Returns:
string - String representation of text shadow.Params:
| Name | Type | Default | Description |
|---|---|---|---|
| textShadow | anychart.graphics.vector.TextShadow | string | 'none' | Text shadow to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
title
Returns:
anychart.core.ui.Title - Title settings.var title = legend.title();
- null/boolean - disable or enable legend title.
- string - sets legend title text value.
- object - sets legend title settings.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | null | boolean | Object | string | false | Title settings to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.titleFormat
Returns:
string | function - Token or function to format title.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| format | string | function | Token or function to format title. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
titleSeparator
Returns:
anychart.core.ui.Separator - Title separator settings.var titleSeparator = legend.titleSeparator();
- null/boolean - disable or enable title separator.
- object - sets separator settings.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | Object | boolean | null | false | Title separator settings to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.tooltip
- null/boolean - disable or enable tooltip.
- object - sets tooltip settings.
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| settings | Object | boolean | null | true | Tooltip settings to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.useHtml
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enabled state to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
vAlign
Returns:
anychart.graphics.vector.Text.VAlign | string - Text vertical align.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| align | anychart.graphics.vector.Text.VAlign | string | 'top' | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
width
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| width | number | string | null | null | Legend width to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
wordBreak
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| mode | anychart.enums.WordBreak | string | "normal" | Word-break mode to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
wordWrap
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| mode | anychart.enums.WordWrap | string | 'normal' | Word-wrap mode to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
zIndex
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| zIndex | number | 0 | Value to set. |
Returns:
anychart.core.ui.Legend - Self instance for method chaining.Try it:
