AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.annotations.Rectangle Improve this Doc

Extends: anychart.core.annotations.Base

Rectangle annotation.

Methods Overview

Specific settings
getPlot()Returns the plot on which the annotation is drawn.
getType()Returns annotation type.
markers()Markers settings.
Axes and Scales
xScale()X-scale settings
yScale()Y-scale settings
Charts
getChart()Returns the chart on which the annotation is drawn.
Coloring
color()Color settings.
fill()Fill settings.
hatchFill()Hatch fill settings.
stroke()Stroke settings.
Interactivity
allowEdit()Interactivity settings.
enabled()Element state (enabled or disabled).
hovered()Hovered state settings.
normal()Normal state settings.
select()Selects current annotation.
selected()Selected state settings.
Size and Position
bottom()Bottom bound settings.
bounds()Bounds settings.
getPixelBounds()Returns pixel bounds.
height()Height settings.
hoverGap()Hover gap settings.
left()Left bound settings.
maxHeight()Maximum height.
maxWidth()Maximum width.
minHeight()Minimum height.
minWidth()Minimum width.
right()Right bound settings.
secondValueAnchor()Second value anchor settings
secondXAnchor()Second X anchor settings
top()Top bound settings.
valueAnchor()Value anchor settings
width()Width settings.
xAnchor()X anchor settings
zIndex()Z-index of the element.

Methods Description

allowEdit

Getter for an interactivity in the annotation.

Returns:

boolean - Interactivity settings.
See listing.
var allowEdit = annotation.allowEdit();
Setter for an interactivity in the annotation.

Params:

NameTypeDescription
value*Whether to disable the interactivity in the annotation. If set to false, the interactivity is disabled in the annotation.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

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.annotations.Rectangle - Returns self 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.annotations.Rectangle - 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.annotations.Rectangle - Self instance for method chaining.

color

Getter for the annotation color.

Returns:

string - The annotation color.
See listing.
var color = annotation.color();
Setter for the annotation color.

Params:

NameTypeDescription
colorstringColor as a string.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - Self instance for method chaining.
Example.
if (!element.enabled())
   element.enabled(true);

fill

Getter for the annotation fill color.

Returns:

anychart.graphics.vector.Fill - The annotation fill color.
See listing.
var fill = annotation.fill();
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.annotations.Rectangle - Self instance for method chaining.
Setter for fill settings using function.

Params:

NameTypeDefaultDescription
fillFunctionfunction():anychart.graphics.vector.Fill
function() {
 return anychart.color.darken(this.sourceColor);
}
Function that looks like:
function(){
   // this.index - series index.
   // this.sourceColor - color returned by fill() getter.
   // this.iterator - series point iterator.
   return fillValue; // type anychart.graphics.vector.Fill
}

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.
Fill color with opacity.

Params:

NameTypeDescription
colorstringColor as a string.
opacitynumberColor opacity (0 to 1).

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - 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.
opacitynumberOpacity of the gradient.
fxnumberX ratio of focal point.
fynumberY ratio of focal point.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

Params:

NameTypeDescription
imageSettingsanychart.graphics.vector.FillObject with settings.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

getChart

Returns the chart on which the annotation is drawn.

getPixelBounds

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

Returns:

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

getPlot

Returns the plot on which the annotation is drawn.

Returns:

anychart.core.stock.Plot - Stock plot.

getType

Returns annotation type.

Returns:

anychart.enums.AnnotationTypes | string - Annotation type

hatchFill

Getter for hatch fill settings.
See listing
var hatchFill = annotation.hatchFill();
Setter for hatch fill settings.

Params:

NameTypeDefaultDescription
typeanychart.graphics.vector.HatchFill.HatchFillType | string
false
Type of hatch fill.
colorstring
Color.
thicknessnumber
Thickness.
sizenumber
Pattern size.

Returns:

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

Params:

NameTypeDescription
hatchFillFunctionfunctionHatchFill function.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - 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.annotations.Rectangle - Self instance for method chaining.
Setter for hatch fill using boolean. Learn more about hatch fill settings.

Params:

NameTypeDefaultDescription
enabledboolean
false
Whether to enable hatch fill or no.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

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.annotations.Rectangle - Returns self for method chaining.

hoverGap

Getter for the hover gap.

Returns:

number - The hover gap value.
See listing.
var hoverGap = annotation.hoverGap();
Setter for the hover gap.
The contour size around annotation.

Params:

NameTypeDescription
value*Value to set.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

hovered

Getter for hovered state settings.

Returns:

anychart.core.StateSettings - Hovered state settings
Setter for hovered state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

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

markers

Getter for data markers.

Returns:

anychart.core.ui.MarkersFactory - Markers instance.
Setter for data markers.

Params:

NameTypeDefaultDescription
settingsObject | boolean | null | string
false
Data markers settings.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - 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.annotations.Rectangle - 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.annotations.Rectangle - 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.annotations.Rectangle - Self instance for method chaining.

normal

Getter for normal state settings.

Returns:

anychart.core.StateSettings - Normal state settings.
Setter for normal state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - Returns self for method chaining.

secondValueAnchor

Getter for the second value anchor.

Returns:

* - The second value anchor.
See listing.
var controller = chart.annotations();
var annotation = controller.rectangle();
var secondValueAnchor = annotation.secondValueAnchor();
Setter for the second value anchor.

Params:

NameTypeDescription
value*Second value anchor to set.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

secondXAnchor

Getter for the second X anchor.

Returns:

* - The second X anchor.
See listing.
var controller = chart.annotations();
var annotation = controller.rectangle();
var secondXAnchor = annotation.secondXAnchor();
Setter for the second X anchor.

Params:

NameTypeDescription
value*Second X anchor to set.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

select

Selects current annotation.

selected

Getter for selected state settings.

Returns:

anychart.core.StateSettings - Selected state settings
Setter for selected state settings.

Params:

NameTypeDescription
settingsObjectState settings to set.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

stroke

Getter for annotation stroke settings.

Returns:

anychart.graphics.vector.Stroke - Stroke settings.
See listing.
var stroke = annotation.stroke();
Setter for the annotation stroke by function.

Params:

NameTypeDefaultDescription
strokeFunctionfunction():anychart.graphics.vector.Stroke|anychart.graphics.vector.ColoredFill
function() {
 return anychart.color.darken(this.sourceColor);
}
Function that looks like:
function(){
   // this.index - series index.
   // this.sourceColor - color returned by fill() getter.
   // this.iterator - series point iterator.
   return strokeValue; // type anychart.graphics.vector.Stroke or anychart.graphics.vector.ColoredFill
}

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.
Setter for annotation stroke settings. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
coloranychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | 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
Line cap style.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.
Setter for annotation stroke settings using an object.

Params:

NameTypeDescription
settingsObjectObject with stroke settings from anychart.graphics.vector.Stroke

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - Returns self for method chaining.

valueAnchor

Getter for the value anchor.

Returns:

* - The value anchor.
See listing.
var controller = chart.annotations();
var annotation = controller.rectangle();
var valueAnchor = annotation.valueAnchor();
Setter for the value anchor.

Params:

NameTypeDescription
value*Value anchor to set.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - Returns self for method chaining.

xAnchor

Getter for the X anchor.

Returns:

* - The X anchor.
See listing.
var controller = chart.annotations();
var annotation = controller.rectangle();
var xAnchor = annotation.xAnchor();
Setter for the X anchor.

Params:

NameTypeDescription
value*X anchor to set.

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

xScale

Setter for the X-scale.

Params:

NameTypeDefaultDescription
settingsanychart.scales.Base | anychart.scales.StockScatterDateTime | Object | anychart.enums.ScaleTypes | string
anychart.scales.Linear
Value to set

Returns:

anychart.core.annotations.Rectangle - Self instance for method chaining.

yScale

Getter for the Y-scale.

Returns:

anychart.scales.Base - Default scale value.
Setter for the Y-scale.

Params:

NameTypeDefaultDescription
settingsanychart.scales.Base | Object | anychart.enums.ScaleTypes | string
anychart.scales.Linear
Y-scale to set.

Returns:

anychart.core.annotations.Rectangle - 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.annotations.Rectangle - Self instance for method chaining.