class anychart.core.utils.LegendItemSettings Improve this Doc
Extends: anychart.core.Text
Legend items are child elements of a legend.
The LegendItemSettings class contains different settings for an icon in the legend item.
Such as text spacing, type, fill, stroke, hatch fill, size, icon marker settings, etc.
Methods Overview
| Specific settings | |
| format() | Item text. |
| text() | Item text. |
| Icon settings | |
| iconEnabled() | Settings showing icons. |
| iconFill() | Icon fill settings |
| iconHatchFill() | Icon hatch fill settings |
| iconMarkerFill() | Icon marker fill settings. |
| iconMarkerStroke() | Icon marker stroke settings. |
| iconMarkerType() | Marker type. |
| iconSize() | Icon size. |
| iconStroke() | Icon stroke settings |
| iconTextSpacing() | Spacing between icon and text |
| iconType() | Icon type 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. |
| vAlign() | Text vertical align settings. |
| Events | |
| disablePointerEvents() | Pointer events settings. |
| Interactivity | |
| disabled() | State settings. |
| enabled() | Element state (enabled or disabled). |
| selectable() | Text selectable option. |
| Size and Position | |
| zIndex() | Z-index of the element. |
| Text Settings | |
| textSettings() | Text settings. |
Methods Description
disablePointerEvents
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enabled state to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
disabled
Returns:
boolean - Disabled setting.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| enabled | boolean | Enabled state to set. |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
fontOpacity
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| opacity | number | 1 | Value to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
fontSize
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| size | string | number | 16 | Font size to set. |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
format
Returns:
string - Legend item format.Learn more about using the format() method.
Params:
| Name | Type | Description |
|---|---|---|
| format | string | function | Function or string token to format legend item text. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.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.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconEnabled
Returns:
boolean - IconEnabled settings.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| enabled | boolean | Whether to show item icon or not. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconFill
Returns:
anychart.graphics.vector.Fill | function - Icon fill settings.Params:
| Name | Type | Description |
|---|---|---|
| color | anychart.graphics.vector.Fill | Array.<(anychart.graphics.vector.GradientKey|string)> | Color as an array, an object or a string. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Params:
| Name | Type | Description |
|---|---|---|
| color | string | Color as a string. |
| opacity | number | Color opacity. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| keys | Array.<(anychart.graphics.vector.GradientKey|string)> | Gradient keys. |
| angle | number | Gradient angle. |
| mode | boolean | anychart.graphics.vector.Rect | Object | Gradient mode. |
| opacity | number | Gradient opacity. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| keys | Array.<(anychart.graphics.vector.GradientKey|string)> | Color-stop gradient keys. |
| cx | number | X ratio of center radial gradient. |
| cy | number | Y ratio of center radial gradient. |
| mode | anychart.graphics.math.Rect | If defined then userSpaceOnUse mode, else objectBoundingBox. |
| opacity | number | Gradient opacity. |
| fx | number | X ratio of focal point. |
| fy | number | Y ratio of focal point. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconHatchFill
Returns:
anychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function - Icon hatch fill.Params:
| Name | Type | Description |
|---|---|---|
| type | anychart.graphics.vector.HatchFill.HatchFillType | string | Type of hatch fill. |
| color | string | Color. |
| thickness | number | Thickness. |
| size | number | Pattern size. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| iconHatchFillFunction | function | HatchFill function. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| patternFill | anychart.graphics.vector.PatternFill | Pattern fill to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| settings | anychart.graphics.vector.HatchFill | Hatch fill instance. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconMarkerFill
Returns:
anychart.graphics.vector.Fill | string - Fill settings.Params:
| Name | Type | Description |
|---|---|---|
| color | anychart.graphics.vector.Fill | Color as a string. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| color | string | Color as a string. |
| opacity | number | Color opacity. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Params:
| Name | Type | Description |
|---|---|---|
| keys | Array.<(anychart.graphics.vector.GradientKey|string)> | Gradient keys. |
| angle | number | Gradient angle. |
| mode | boolean | anychart.graphics.vector.Rect | Object | Gradient mode. |
| opacity | number | Gradient opacity. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Params:
| Name | Type | Description |
|---|---|---|
| keys | Array.<(anychart.graphics.vector.GradientKey|string)> | Color-stop gradient keys. |
| cx | number | X ratio of center radial gradient. |
| cy | number | Y ratio of center radial gradient. |
| mode | anychart.graphics.math.Rect | If defined then userSpaceOnUse mode, else objectBoundingBox. |
| opacity | number | Opacity of the gradient. |
| fx | number | X ratio of focal point. |
| fy | number | Y ratio of focal point. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Params:
| Name | Type | Description |
|---|---|---|
| imageSettings | anychart.graphics.vector.Fill | Object with settings. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.iconMarkerStroke
Returns:
anychart.graphics.vector.Stroke | string - Icon marker stroke settings.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| color | anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Stroke settings. | |
| thickness | number | 1 | Line thickness. |
| dashpattern | string | Controls the pattern of dashes and gaps used to stroke paths. | |
| lineJoin | string | anychart.graphics.vector.StrokeLineJoin | Line join style. | |
| lineCap | string | anychart.graphics.vector.StrokeLineCap | Style of line cap. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconMarkerType
Returns:
anychart.enums.MarkerType | string | function - Icon marker type.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| type | anychart.enums.MarkerType | string | function | Marker type to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconSize
Params:
| Name | Type | Description |
|---|---|---|
| size | number | string | Icon size to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self for method chaining.Try it:
iconStroke
Returns:
function | anychart.graphics.vector.Stroke - Icon stroke.Params:
| Name | Type | Description |
|---|---|---|
| strokeFunction | function():anychart.graphics.vector.Stroke|anychart.graphics.vector.ColoredFill | Function that looks like: function(){
// this.sourceColor - color returned by fill() getter.
return strokeValue; // type anychart.graphics.vector.Fill or anychart.graphics.vector.Stroke
} |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| color | anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | null | Stroke settings. |
| thickness | number | Line thickness. | |
| dashpattern | string | Controls the pattern of dashes and gaps used to stroke paths. | |
| lineJoin | string | anychart.graphics.vector.StrokeLineJoin | Line join style. | |
| lineCap | string | anychart.graphics.vector.StrokeLineCap | Line cap style. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| settings | Object | Stroke settings from anychart.graphics.vector.Stroke. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconTextSpacing
Returns:
number - Spacing between icon and text.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| spacing | number | Value of spacing between icon and text. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
iconType
Returns:
anychart.enums.LegendItemIconType | string | function - Icon type or drawer function.Try it:
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| type | anychart.enums.LegendItemIconType | string | function(path:anychart.graphics.vector.Path, size:number) | 'square' |
Icon type or custom drawer function. Function for a custom
icon should look like this: function(path, size){
// path - anychart.graphics.vector.Path
// size - icon size
... //do something
} |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
text
Returns:
string - Legend item text.Try it:
Params:
| Name | Type | Description |
|---|---|---|
| text | string | function | Legend item text. |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
textIndent
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| indent | number | 0 | Text indent to set. |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
useHtml
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | false | Enabled state to set. |
Returns:
anychart.core.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - 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.utils.LegendItemSettings - Self instance for method chaining.Try it:
zIndex
Params:
| Name | Type | Default | Description |
|---|---|---|---|
| zIndex | number | 0 | Value to set. |
Returns:
anychart.core.utils.LegendItemSettings - Self instance for method chaining.Try it:
