AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.ui.Background Improve this Doc

Extends: anychart.core.VisualBaseWithBounds

Background element class.
Background can be a part of another complex element (chart, legend, title and so on), or used separately.
Background has a fill, a border and corner shape settings.
Note: Always specify display bounds if you use Background separately.

Methods Overview

Specific settings
cornerType()Corner type.
corners()Corner radius.
disablePointerEvents()Pointer events settings.
Coloring
bottomStroke()Bottom stroke settings.
fill()Fill settings.
leftStroke()Left stroke settings.
rightStroke()Right stroke settings.
stroke()Stroke settings.
topStroke()Top stroke settings.
Interactivity
enabled()Element state (enabled or disabled).
Size and Position
bottom()Bottom bound settings.
bounds()Bounds settings.
getPixelBounds()Returns pixel bounds.
height()Height settings.
left()Left bound settings.
maxHeight()Maximum height.
maxWidth()Maximum width.
minHeight()Minimum height.
minWidth()Minimum width.
right()Right bound settings.
top()Top bound settings.
width()Width settings.
zIndex()Z-index of the element.

Methods Description

bottom

Getter for element bottom bound settings.

Returns:

number | string | undefined - Element's bottom bound setting.
Setter for element bottom bound settings.

Params:

NameTypeDefaultDescription
bottomnumber | string | null
null
Bottom bound settings for the element.

Returns:

anychart.core.ui.Background - Returns self for method chaining.

bottomStroke

Getter for the bottom stroke.

Returns:

anychart.graphics.vector.Stroke - Returns bottom stroke.
See listing
var bottomStroke = background.bottomStroke();
Setter for bottom stroke settings using one parameter.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Object
'none'
Stroke formatted as '[thickness ]color[ opacity]'.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for bottom stroke settings.

Params:

NameTypeDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | stringStroke settings.
thicknessnumberLine thickness. Defaults to 1 of not set.
dashpatternstringControls the pattern of dashes and gaps used to stroke paths. Dash array contains a list of white space separated lengths and percentages that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, stroke dashpattern: '5 3 2' is equivalent to dashpattern: '5 3 2 5 3 2'.
lineJoinstring | anychart.graphics.vector.StrokeLineJoinLine join style.
lineCapstring | anychart.graphics.vector.StrokeLineCapLine cap style.

Returns:

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

bounds

Getter for element bounds settings.

Returns:

anychart.core.utils.Bounds - Bounds of the element.
Setter for bounds of the element using one parameter.

Params:

NameTypeDescription
boundsanychart.utils.RectObj | anychart.math.Rect | anychart.core.utils.BoundsBounds of element.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for element bounds settings.

Params:

NameTypeDefaultDescription
xnumber | string
null
X-coordinate.
ynumber | string
null
Y-coordinate.
widthnumber | string
null
Width.
heightnumber | string
null
Height.

Returns:

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

cornerType

Getter for the corner type.

Returns:

anychart.enums.BackgroundCornersType | string - Corners type.
Setter for the corner type.

Params:

NameTypeDefaultDescription
typeanychart.enums.BackgroundCornersType | string
'round'
Value to set.

Returns:

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

corners

Getter for the corner radius.

Returns:

Array.<number> - Corner settings.
Setter for the corner radius by one value.

Params:

NameTypeDefaultDescription
cornersnumber | string | Array.<number>
0
Value to set.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for the corner radius by each value.

Params:

NameTypeDescription
topLeftnumber | stringTop left corner value.
topRightnumber | stringTop right corner value.
bottomRightnumber | stringBottom left corner value.
bottomLeftnumber | stringBottom right corner value.

Returns:

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

disablePointerEvents

Getter for the pointer events settings.

Returns:

boolean - The pointer events settings.
See listing
var names = background.names();
var disablePointerEvents = names.disablePointerEvents();
Setter for the pointer events setting.

Params:

NameTypeDefaultDescription
enabledboolean
false
Value to set.

Returns:

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

enabled

Getter for the element state (enabled or disabled).

Returns:

boolean - Element state.
See listing
var enabled = background.enabled();
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
enabledboolean
true
Enabled state to set.

Returns:

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

fill

Getter for the background fill.

Returns:

anychart.graphics.vector.Fill - Fill settings (empty fill is always 'none').
Setter for fill settings using an object, an array or a string.
Accepts: or a color as a string, along with opacity, if needed, format is "Color Opacity", e.g. "red 0.5".

Params:

NameTypeDescription
coloranychart.graphics.vector.Fill | Array.<(anychart.graphics.vector.GradientKey|string)>Fill as an object, an array or a string.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Fill as a color with opacity.

Params:

NameTypeDefaultDescription
colorstring
"#fff"
Fill as a string.
opacitynumber
Fill opacity.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Linear gradient fill.

Params:

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

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Radial gradient fill.

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.ui.Background - Self instance for method chaining.

getPixelBounds

Returns pixel bounds of the element due to parent bounds and self bounds settings.

Returns:

anychart.math.Rect - Pixel bounds of the element.

height

Getter for element height settings.

Returns:

number | string | undefined - Element's height setting.
Setter for element height setting.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Height settings for the element.

Returns:

anychart.core.ui.Background - Returns self for method chaining.

left

Getter for element left bound settings.

Returns:

number | string | undefined - Element's left bound setting.
Setter for element left bound settings.

Params:

NameTypeDefaultDescription
leftnumber | string | null
null
Left bound setting for the element.

Returns:

anychart.core.ui.Background - Returns self for method chaining.

leftStroke

Getter for the left stroke.

Returns:

anychart.graphics.vector.Stroke - Returns left stroke.
See listing
var leftStroke = background.leftStroke();
Setter for left stroke settings using one parameter.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Object
'none'
Stroke formatted as '[thickness ]color[ opacity]'.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for left stroke settings.

Params:

NameTypeDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | stringStroke settings.
thicknessnumberLine thickness. Defaults to 1 of not set.
dashpatternstringControls the pattern of dashes and gaps used to stroke paths. Dash array contains a list of white space separated lengths and percentages that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, stroke dashpattern: '5 3 2' is equivalent to dashpattern: '5 3 2 5 3 2'.
lineJoinstring | anychart.graphics.vector.StrokeLineJoinLine join style.
lineCapstring | anychart.graphics.vector.StrokeLineCapLine cap style.

Returns:

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

maxHeight

Getter for the maximum height.

Returns:

number | string | null - Element's maximum height.
Setter for the maximum height.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Maximum height to set.

Returns:

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

maxWidth

Getter for the maximum width.

Returns:

number | string | null - Element's maximum width.
Setter for the maximum width.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Maximum width to set.

Returns:

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

minHeight

Getter for the minimum height.

Returns:

number | string | null - Element's minimum height.
Setter for the minimum height.

Params:

NameTypeDefaultDescription
heightnumber | string | null
null
Minimum height to set.

Returns:

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

minWidth

Getter for the minimum width.

Returns:

number | string | null - Element's minimum width.
Setter for the minimum width.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Minimum width to set.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Getter for element right bound settings.

Returns:

number | string | undefined - Element's right bound setting.
Setter for element right bound setting.

Params:

NameTypeDefaultDescription
rightnumber | string | null
null
Right bound setting for the element.

Returns:

anychart.core.ui.Background - Returns self for method chaining.

rightStroke

Getter for the right stroke.

Returns:

anychart.graphics.vector.Stroke - Returns right stroke.
See listing
var rightStroke = background.rightStroke();
Setter for right stroke settings using one parameter.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Object
'none'
Stroke formatted as '[thickness ]color[ opacity]'.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for right stroke settings.

Params:

NameTypeDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | stringStroke settings.
thicknessnumberLine thickness. Defaults to 1 of not set.
dashpatternstringControls the pattern of dashes and gaps used to stroke paths. Dash array contains a list of white space separated lengths and percentages that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, stroke dashpattern: '5 3 2' is equivalent to dashpattern: '5 3 2 5 3 2'.
lineJoinstring | anychart.graphics.vector.StrokeLineJoinLine join style.
lineCapstring | anychart.graphics.vector.StrokeLineCapLine cap style.

Returns:

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

stroke

Getter for the background stroke.

Returns:

anychart.graphics.vector.Stroke - Returns stroke.
Setter for stroke settings using one parameter.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Object
'none'
Stroke formatted as '[thickness ]color[ opacity]'.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for stroke settings.

Params:

NameTypeDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | stringStroke settings.
thicknessnumberLine thickness. Defaults to 1 of not set.
dashpatternstringControls the pattern of dashes and gaps used to stroke paths. Dash array contains a list of white space separated lengths and percentages that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, stroke dashpattern: '5 3 2' is equivalent to dashpattern: '5 3 2 5 3 2'.
lineJoinstring | anychart.graphics.vector.StrokeLineJoinLine join style.
lineCapstring | anychart.graphics.vector.StrokeLineCapLine cap style.

Returns:

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

top

Getter for element top bound settings.

Returns:

number | string | undefined - Element's top bound setting.
Setter for element top bound settings.

Params:

NameTypeDefaultDescription
topnumber | string | null
null
Top bound setting for the element.

Returns:

anychart.core.ui.Background - Returns self for method chaining.

topStroke

Getter for the top stroke.

Returns:

anychart.graphics.vector.Stroke - Returns top stroke.
See listing
var topStroke = background.topStroke();
Setter for top stroke settings using one parameter.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null | Object
'none'
Stroke formatted as '[thickness ]color[ opacity]'.

Returns:

anychart.core.ui.Background - Self instance for method chaining.
Setter for top stroke settings.

Params:

NameTypeDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | stringStroke settings.
thicknessnumberLine thickness. Defaults to 1 of not set.
dashpatternstringControls the pattern of dashes and gaps used to stroke paths. Dash array contains a list of white space separated lengths and percentages that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, stroke dashpattern: '5 3 2' is equivalent to dashpattern: '5 3 2 5 3 2'.
lineJoinstring | anychart.graphics.vector.StrokeLineJoinLine join style.
lineCapstring | anychart.graphics.vector.StrokeLineCapLine cap style.

Returns:

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

width

Getter for element width settings.

Returns:

number | string | undefined - Element's width setting.
Setter for element width setting.

Params:

NameTypeDefaultDescription
widthnumber | string | null
null
Width settings for the element.

Returns:

anychart.core.ui.Background - Returns self 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.ui.Background - Self instance for method chaining.