AnyChart
API Reference
Still have questions?
Contact support
Top

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

Getter for the pointer events.

Returns:

boolean - Flag of the state.
Setter for the pointer events.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

disabled

Getter for disabled settings.

Returns:

boolean - Disabled setting.
Setter for disabled settings.

Params:

NameTypeDescription
enabledbooleanEnabled state to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

enabled

Getter for the element state (enabled or disabled).

Returns:

boolean - Element state.
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
enabledboolean
true
Enabled state to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Example.
if (!element.enabled())
   element.enabled(true);

fontColor

Getter for the text font color.

Returns:

string - Font color.
Setter for the text font color.
https://www.w3schools.com/html/html_colors.asp

Params:

NameTypeDefaultDescription
colorstring
'#7c868e'
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontDecoration

Getter for the text font decoration.

Returns:

anychart.graphics.vector.Text.Decoration | string - Font decoration.
Setter for the text font decoration.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Decoration | string
'none'
Font decoration to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontFamily

Getter for the font family.

Returns:

string - Font family.
Setter for the font family.

Params:

NameTypeDefaultDescription
familystring
'Verdana', Helvetica, Arial, sans-serif
Font family to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontOpacity

Getter for the text font opacity.

Returns:

number - Font opacity.
Setter for the text font opacity. Double value from 0 to 1.

Params:

NameTypeDefaultDescription
opacitynumber
1
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontSize

Getter for the text font size.

Returns:

string | number - Font size.
Setter for the text font size.

Params:

NameTypeDefaultDescription
sizestring | number
16
Font size to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontStyle

Getter for the text font style.

Returns:

anychart.graphics.vector.Text.FontStyle | string - Font style.
Setter for the text font style.

Params:

NameTypeDefaultDescription
styleanychart.graphics.vector.Text.FontStyle | string
'normal'
Font style to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontVariant

Getter for the text font variant.

Returns:

anychart.graphics.vector.Text.FontVariant | string - Font variant.
Setter for the text font variant.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.FontVariant | string
'normal'
Font variant to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

fontWeight

Getter for the text font weight.

Returns:

string | number - Font weight.

Params:

NameTypeDefaultDescription
weightstring | number
'normal'
Font weight to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

format

Getter for legend item format settings.

Returns:

string - Legend item format.

Params:

NameTypeDescription
formatstring | functionFunction or string token to format legend item text.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

hAlign

Getter for the text horizontal align.

Returns:

anychart.graphics.vector.Text.HAlign | string - Text horizontal align.
Setter for the text horizontal align.

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.HAlign | string
'start'
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconEnabled

Getter for settings showing icons.

Returns:

boolean - IconEnabled settings.
Setter for settings showing icons.

Params:

NameTypeDescription
enabledbooleanWhether to show item icon or not.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconFill

Getter for legend item icon fill settings.

Returns:

anychart.graphics.vector.Fill | function - Icon fill settings.
Setter for fill settings using an array, an object or a string. Learn more about coloring.

Params:

NameTypeDescription
coloranychart.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.
Fill color with opacity.

Params:

NameTypeDescription
colorstringColor as a string.
opacitynumberColor opacity.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Linear gradient fill. Learn more about coloring.

Params:

NameTypeDescription
keysArray.<(anychart.graphics.vector.GradientKey|string)>Gradient keys.
anglenumberGradient angle.
modeboolean | anychart.graphics.vector.Rect | ObjectGradient mode.
opacitynumberGradient opacity.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Radial gradient fill. Learn more about coloring.

Params:

NameTypeDescription
keysArray.<(anychart.graphics.vector.GradientKey|string)>Color-stop gradient keys.
cxnumberX ratio of center radial gradient.
cynumberY ratio of center radial gradient.
modeanychart.graphics.math.RectIf defined then userSpaceOnUse mode, else objectBoundingBox.
opacitynumberGradient opacity.
fxnumberX ratio of focal point.
fynumberY ratio of focal point.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconHatchFill

Getter for icon hatch fill settings.
Setter for icon hatch fill settings.

Params:

NameTypeDescription
typeanychart.graphics.vector.HatchFill.HatchFillType | stringType of hatch fill.
colorstringColor.
thicknessnumberThickness.
sizenumberPattern size.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Setter for hatch fill settings using function. Learn more about coloring.

Params:

NameTypeDescription
iconHatchFillFunctionfunctionHatchFill function.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Setter for hatch fill settings using pattern fill. Learn more about coloring.

Params:

NameTypeDescription
patternFillanychart.graphics.vector.PatternFillPattern fill to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Setter for hatch fill settings using an instance. Learn more about coloring.

Params:

NameTypeDescription
settingsanychart.graphics.vector.HatchFillHatch fill instance.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconMarkerFill

Getter for icon marker fill settings.

Returns:

anychart.graphics.vector.Fill | string - Fill settings.
Setter for icon marker fill settings using a string. Learn more about coloring.

Params:

NameTypeDescription
coloranychart.graphics.vector.FillColor as a string.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Icon marker fill color with opacity.

Params:

NameTypeDescription
colorstringColor as a string.
opacitynumberColor opacity.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Linear gradient fill for icon marker. Learn more about coloring.

Params:

NameTypeDescription
keysArray.<(anychart.graphics.vector.GradientKey|string)>Gradient keys.
anglenumberGradient angle.
modeboolean | anychart.graphics.vector.Rect | ObjectGradient mode.
opacitynumberGradient opacity.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Radial gradient fill for icon marker. Learn more about coloring.

Params:

NameTypeDescription
keysArray.<(anychart.graphics.vector.GradientKey|string)>Color-stop gradient keys.
cxnumberX ratio of center radial gradient.
cynumberY ratio of center radial gradient.
modeanychart.graphics.math.RectIf defined then userSpaceOnUse mode, else objectBoundingBox.
opacitynumberOpacity of the gradient.
fxnumberX ratio of focal point.
fynumberY ratio of focal point.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Image fill for icon marker. Learn more about coloring.

Params:

NameTypeDescription
imageSettingsanychart.graphics.vector.FillObject with settings.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconMarkerStroke

Getter for icon marker stroke settings.

Returns:

anychart.graphics.vector.Stroke | string - Icon marker stroke settings.
Setter for icon marker stroke settings.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null
Stroke settings.
thicknessnumber
1
Line thickness.
dashpatternstring
Controls the pattern of dashes and gaps used to stroke paths.
lineJoinstring | anychart.graphics.vector.StrokeLineJoin
Line join style.
lineCapstring | anychart.graphics.vector.StrokeLineCap
Style of line cap.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconMarkerType

Getter for the marker type.

Returns:

anychart.enums.MarkerType | string | function - Icon marker type.
Setter for the marker type.

Params:

NameTypeDescription
typeanychart.enums.MarkerType | string | functionMarker type to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconSize

Getter for the icon size of legend item.

Returns:

number - Icon size setting.
Setter for the icon size of legend item.

Params:

NameTypeDescription
sizenumber | stringIcon size to set.

Returns:

anychart.core.utils.LegendItemSettings - Self for method chaining.

iconStroke

Getter for legend item icon stroke settings.

Returns:

function | anychart.graphics.vector.Stroke - Icon stroke.
Setter for legend item icon stroke using a function. Learn more about stroke settings.

Params:

NameTypeDescription
strokeFunctionfunction():anychart.graphics.vector.Stroke|anychart.graphics.vector.ColoredFillFunction 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.
Setter for legend item icon stroke settings. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null
null
Stroke settings.
thicknessnumber
Line thickness.
dashpatternstring
Controls the pattern of dashes and gaps used to stroke paths.
lineJoinstring | anychart.graphics.vector.StrokeLineJoin
Line join style.
lineCapstring | anychart.graphics.vector.StrokeLineCap
Line cap style.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.
Setter for legend item icon stroke using an object.

Params:

NameTypeDescription
settingsObjectStroke settings from anychart.graphics.vector.Stroke.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconTextSpacing

Getter for a spacing between icon and text.

Returns:

number - Spacing between icon and text.
Setter for a spacing between icon and text.

Params:

NameTypeDescription
spacingnumberValue of spacing between icon and text.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

iconType

Getter for the icon type.

Returns:

anychart.enums.LegendItemIconType | string | function - Icon type or drawer function.
Setter for the icon type.

Params:

NameTypeDefaultDescription
typeanychart.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.

letterSpacing

Getter for the text letter spacing.

Returns:

string | number - Letter spacing.

Params:

NameTypeDefaultDescription
spacingstring | number
'normal'
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

lineHeight

Getter for the text line height.

Returns:

string | number - Text line height.

Params:

NameTypeDefaultDescription
heightstring | number
'normal'
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

selectable

Getter for the text selectable option.

Returns:

boolean - The text selectable option.
Setter for the text selectable.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

text

Getter for the legend item text.

Returns:

string - Legend item text.
Setter for the legend item text.

Params:

NameTypeDescription
textstring | functionLegend item text.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

textDirection

Getter for the text direction.

Returns:

anychart.graphics.vector.Text.Direction | string - Text direction.
Setter for the text direction.

Params:

NameTypeDefaultDescription
directionanychart.graphics.vector.Text.Direction | string
'ltr'
Text direction to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

textIndent

Getter for the text indent.

Returns:

number - Text indent.
Setter for the text indent.

Params:

NameTypeDefaultDescription
indentnumber
0
Text indent to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

textOverflow

Getter for the text overflow settings.

Returns:

anychart.graphics.vector.Text.TextOverflow | string - Text overflow settings.
See listing
var title = chart.title();
var textOverflow = title.textOverflow();
Setter for the text overflow settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextOverflow | string
""
Text overflow settings to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

textSettings

Getter for the full text appearance settings.

Returns:

Object - A copy of settings object.
Getter for all text appearance settings.

Params:

NameTypeDescription
namestringSetting name.

Returns:

string | number | boolean | undefined - Value of settings.
Setter for text appearance settings.

Params:

NameTypeDescription
objectWithSettingsObjectSettings 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.
Setter for the text appearance settings.

Params:

NameTypeDescription
namestringSetting name.
settingsstring | number | boolean | functionText settings.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

useHtml

Getter for the useHTML flag.

Returns:

boolean - Value of useHTML flag.
Setter for flag useHTML.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

vAlign

Getter for the text vertical align.

Returns:

anychart.graphics.vector.Text.VAlign | string - Text vertical align.
Setter for the text vertical align.

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.VAlign | string
'top'
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

wordBreak

Getter for the word-break mode.

Returns:

anychart.enums.WordBreak | string - Word-break mode.
Setter for the word-break mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordBreak | string
"normal"
Word-break mode to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

wordWrap

Getter for the word-wrap mode.

Returns:

anychart.enums.WordWrap | string - Word-wrap mode.
Setter for the word-wrap mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordWrap | string
'normal'
Word-wrap mode to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.

zIndex

Getter for the Z-index of the element.

Returns:

number - Z-index.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
zIndexnumber
0
Value to set.

Returns:

anychart.core.utils.LegendItemSettings - Self instance for method chaining.