AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.8.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

class anychart.graphics.vector.PatternFill Improve this Doc

Extends: anychart.graphics.vector.Layer

Pattern fill class.
Do not invoke constructor directly. Use anychart.graphics#patternFill.

Methods Overview

Miscellaneous
addChild()Add element to a layer, to the top (maximal index).
addChildAt()Adds an element to a layer by index.
appendTransformationMatrix()Combines the current transformation with the given transformation matrix.
circle()Invokes anychart.graphics.vector.Circle class constructor.
clip()Sets clipping rectangle.
cursor()Getter for cursor type.
disablePointerEvents()Specifies under what circumstances a given graphics element can be a target element for a pointer event.
domElement()Returns DOM element if element is rendered.
drag()Turns off/on dragging (moving) of an element.
ellipse()Invokes anychart.graphics.vector.Ellipse class constructor.
forEachChild()Applies function to all elements in a layer.
getAbsoluteBounds()Gets element bounds in absolute coordinates (root element coordinate system).
getAbsoluteCoordinate()Returns absolute coordinates (root element coordinate system).
getAbsoluteHeight()Returns height within root bounds.
getAbsoluteSize()Returns size within root bounds.
getAbsoluteWidth()Returns width within root bounds.
getAbsoluteX()Returns an absolute X (root element coordinate system).
getAbsoluteY()Returns an absolute Y (root element coordinate system).
getBounds()Returns bounds.
getChildAt()Returns element by index.
getCoordinate()Returns (X,Y) in the coordinate system of the parent.
getHeight()Returns height.
getRotationAngle()Returns the current rotation angle in degrees.
getSize()Returns size.
getStage()Stage object (to which the given element is bound).
getTransformationMatrix()Returns the current transformation matrix.
getWidth()Returns width.
getX()Returns X in the coordinate system of the parent.
getY()Returns Y in the coordinate system of the parent.
hasChild()Checks if there is such element in children set.
hasParent()Whether parent element is set.
html()Returns anychart.graphics.vector.Text constructoe and applies anychart.graphics.vector.Text#htmlText to handle HTML formatting.
id()Gets element identifier. If it was not set, it will be generated and applied to the DOM.
image()Invokes anychart.graphics.vector.Image class constructor.
indexOfChild()Looks for an element in a layer and returns index or -1, of not found.
layer()Invokes anychart.graphics.vector.Layer class constructor.
listen()Adds an event listener. A listener can only be added once to an
listenOnce()Adds an event listener that is removed automatically after the
numChildren()Returns the number of children.
parent()Returns the parent layer.
path()Invokes anychart.graphics.vector.Path class constructor.
rect()Invokes anychart.graphics.vector.Rect class constructor.
remove()Current element removes itself from the parent layer.
removeAllListeners()Removes all listeners from this listenable. If type is specified,
removeChild()Removes element from a layer.
removeChildAt()Removes element from a layer by index.
removeChildren()Remove all children from a layer.
rotate()Rotates a shape around the given rotation point.
rotateByAnchor()Rotates a shape around the given anchor.
scale()Scales a shape. Scaling center is set in the coordinate system of the parent.
scaleByAnchor()Scales a shape. Scaling center is set as an anchor.
setPosition()Sets top left corner of a shape (transformation taken into account) in the coordinate system of the parent.
setRotation()Rotatates a shape around the given point.
setRotationByAnchor()Rotates a shape around the given anchor.
setTransformationMatrix()Sets transformation matrix.
swapChildren()Swap children.
swapChildrenAt()Swap children by indices.
text()Invokes anychart.graphics.vector.Text class constructor.
translate()Moves a shape taking an account the current transformation.
unlisten()Removes an event listener which was added with listen() or listenOnce().
visible()Gets/sets the current visibility flag.
zIndex()Gets and sets element's zIndex.

Methods Description

addChild

Add element to a layer, to the top (maximal index).
All DOM changes will happen instantly, except anychart.graphics.vector.Stage#suspend.
Simplified version of anychart.graphics.vector.Layer#addChildAt where element is added to the end.

Params:

NameTypeDescription
elementanychart.graphics.vector.ElementElement to add.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

addChildAt

Adds an element to a layer by index.
Note: the greater index is - the 'higher' element is in a layer top element overlaps bottom elements.
All DOM changes will happen instantly, except anychart.graphics.vector.Stage#suspend.

Params:

NameTypeDescription
elementanychart.graphics.vector.ElementElement to add.
indexnumberElement index.
Only positive numbers.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

appendTransformationMatrix

Combines the current transformation with the given transformation matrix. Combination is done via matrix multiplication (multiplication to the right).

Params:

NameTypeDescription
m00numberScale X.
m10numberShear Y.
m01numberShear X.
m11numberScale Y.
m02numberTranslate X.
m12numberTranslate Y.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

circle

Invokes anychart.graphics.vector.Circle class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.
Read more at anychart.graphics.vector.Circle

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
cxnumberCenter X, in pixels.
cynumberCenter Y, in pixels.
radiusnumberRadius, in pixels.

Returns:

anychart.graphics.vector.Circle - An instance of class for method chaining.

clip

Gets/sets clipping rectangle.

Returns:

anychart.graphics.math.Rect - An instance of class for method chaining.
Sets clipping rectangle. Affects display only after render() method call.
Attention! In SVG clip will transform according to transformation, and in VML clip will be surrounding.

Params:

NameTypeDescription
valueanychart.graphics.math.Rect | stringClipping rectangle.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

cursor

Getter for cursor type.

Returns:

anychart.graphics.vector.Cursor - Current cursor type.
Setter for cursor type.

Params:

NameTypeDescription
valueanychart.graphics.vector.CursorCursor type.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

disablePointerEvents

Specifies under what circumstances a given graphics element can be a target element for a pointer event.

Params:

NameTypeDescription
valuebooleanPointer events property value.

Returns:

anychart.graphics.vector.PatternFill | boolean - If opt_value defined then returns Element object for chaining else returns property value.

domElement

Returns DOM element if element is rendered.
In case of Stage in Suspended state or unbound element – null is returned.

Returns:

Element - DOM element.

drag

Returns current state flag.

Returns:

boolean | anychart.graphics.math.Rect - .
Turns off/on dragging (moving) of an element.
Sets mode (true - on, false - off) or dragging area for an element, dragging is always on within an area.

Params:

NameTypeDescription
valueboolean | anychart.graphics.math.RectFlag or a dragging area.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

ellipse

Invokes anychart.graphics.vector.Ellipse class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.
Read more at anychart.graphics.vector.Ellipse

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
cxnumberCenter X, in pixels.
cynumberCenter Y, in pixels.
rxnumberRadius X, in pixels.
rynumberRadius Y, in pixels.

Returns:

anychart.graphics.vector.Ellipse - An instance of class for method chaining.

forEachChild

Applies function to all elements in a layer.

Params:

NameTypeDescription
callbackfunctionFunction to be applied.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.
Applies the function to all elements of a layer in the given context.

Params:

NameTypeDescription
callbackfunctionFunction to be applied.
thisObjectthis context for the function to be applied.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

getAbsoluteBounds

Gets element bounds in absolute coordinates (root element coordinate system).

Returns:

anychart.graphics.math.Rect - Absolute element bounds.

getAbsoluteCoordinate

Returns absolute coordinates (root element coordinate system).
See illustrations at anychart.graphics.vector.Element#getAbsoluteX and anychart.graphics.vector.Element#getAbsoluteY

Returns:

anychart.graphics.math.Coordinate - Absolute coordinates.

getAbsoluteHeight

Returns height within root bounds.

Returns:

number - Height.

getAbsoluteWidth

Returns width within root bounds.

Returns:

number - Width.

getAbsoluteX

Returns an absolute X (root element coordinate system).

Returns:

number - Absolute X.

getAbsoluteY

Returns an absolute Y (root element coordinate system).

Returns:

number - Absolute Y.

getBounds

Returns bounds.

Returns:

anychart.graphics.math.Rect - Bounds.

getChildAt

Returns element by index.

Params:

NameTypeDescription
indexnumberElement to be returned.

Returns:

anychart.graphics.vector.PatternFill - Element or null.

getCoordinate

Returns (X,Y) in the coordinate system of the parent.

Returns:

anychart.graphics.math.Coordinate - (X,Y) in the coordinate system of the parent.

getHeight

Returns height.

Returns:

number - Height.

getRotationAngle

Returns the current rotation angle in degrees.

Returns:

number - Rotation angle.

getSize

Returns size.

getStage

Stage object (to which the given element is bound).

Returns:

anychart.graphics.vector.Stage - Stage object.

getTransformationMatrix

Returns the current transformation matrix as an array of six elements:
[
  {number} m00 Scale X.
  {number} m10 Shear Y.
  {number} m01 Shear X.
  {number} m11 Scale Y.
  {number} m02 Translate X.
  {number} m12 Translate Y.
]

Returns:

Array.<number> - Transformation matrix array.

getWidth

Returns width.

Returns:

number - Width.

getX

Returns X in the coordinate system of the parent.

Returns:

number - X in the coordinate system of the parent.

getY

Returns Y in the coordinate system of the parent.

Returns:

number - Y in the coordinate system of the parent.

hasChild

Checks if there is such element in children set.

Params:

NameTypeDescription
elementanychart.graphics.vector.ElementElement.

Returns:

boolean - True if it is a child.

hasParent

Whether parent element is set.

Returns:

boolean - Whether parent element is set.

html

Invokes anychart.graphics.vector.Text class constructor and applies anychart.graphics.vector.Text#htmlText method to handle HTML formatting.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
xnumberX-coordinate (Left) of top left corner of text bounds.
ynumberY-coordinate (Top) of top left corner of text bounds.
textstringText to be displayed.
styleanychart.graphics.vector.TextStyleText style. More at anychart.graphics.vector.Text#style.

Returns:

anychart.graphics.vector.Text - An instance of class for method chaining.

id

Gets element identifier. If it was not set, it will be generated and applied to the DOM.

Returns:

string - Returns element identifier.
Sets element identifier.

Params:

NameTypeDescription
valuestringCustom identifier.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

image

Invokes anychart.graphics.vector.Image class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
srcstringIRI (Internationalized Resource Identifiers) for image source.
xnumberX coordinate of left-top corner image.
ynumberY coordinate of left-top corner image.
widthnumberWidth of image bounds.
heightnumberHeight of image bounds.

Returns:

anychart.graphics.vector.Image - Image object instance.

indexOfChild

Looks for an element in a layer and returns index or -1, of not found.

Params:

NameTypeDescription
elementanychart.graphics.vector.ElementElement which index we need to find.

Returns:

number - Index or -1, or not found.

layer

Invokes anychart.graphics.vector.Layer class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

listen

Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeSCOPEObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener that is removed automatically after the listener fired once. If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeSCOPEObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

numChildren

Returns the number of children.

Returns:

number - Number of children.

parent

Returns the parent layer.

Returns:

anychart.graphics.vector.PatternFill | anychart.graphics.vector.Stage - Instance of element current layer.
Adds element to the given layer.

Params:

NameTypeDescription
valueanychart.graphics.vector.Layer | anychart.graphics.vector.StageParent layer.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

path

Invokes anychart.graphics.vector.Path class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.
Read more at: anychart.graphics.vector.Path

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param

Returns:

anychart.graphics.vector.Path - An instance of class for method chaining.

rect

Invokes anychart.graphics.vector.Rect class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
xnumberX (Left) of top left rectangle corner.
ynumberY (Top) of to left rectangle corner.
widthnumberRectangle width.
heightnumberRectangle height.

Returns:

anychart.graphics.vector.Rect - An instance of class for method chaining.

remove

Current element removes itself from the parent layer.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

removeAllListeners

Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

removeChild

Removes element from a layer.
All changes in DOM will happen instantly, except anychart.graphics.vector.Stage#suspend.
Note: this method doesn't remove element, it just breaks the link between the element and the layer.
This is an extension of anychart.graphics.vector.Layer#removeChildAt method.

Params:

NameTypeDescription
elementanychart.graphics.vector.ElementElement to remove or its id.

Returns:

anychart.graphics.vector.PatternFill - Removed element or null.

removeChildAt

Removes element from a layer by index.
All changes in DOM will happen instantly, except anychart.graphics.vector.Stage#suspend.
Note: this method doesn't remove element, it just breaks the link between the element and the layer.

Params:

NameTypeDescription
indexnumberIndex of element to be removed.

Returns:

anychart.graphics.vector.PatternFill - Removed element or null.

removeChildren

Remove all children from a layer.

Returns:

Array.<anychart.graphics.vector.Element> - Array of removed elements.

rotate

Rotates a shape around the given rotation point.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
cxnumberRotation point X.
cynumberRotation point Y.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

rotateByAnchor

Rotates a shape around the given anchor.

Params:

NameTypeDescription
degreesnumberRotation angle in degress.
anchoranychart.graphics.vector.Anchor | stringRotation anchor.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

scale

Scales a shape. Scaling center is set in the coordinate system of the parent.

Params:

NameTypeDescription
sxnumberX scaling factor.
synumberY scaling factor.
cxnumberScaling point X.
cynumberScaling point Y.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

scaleByAnchor

Scales a shape. Scaling center is set as an anchor.

Params:

NameTypeDescription
sxnumberX scaling factor.
synumberY scaling factor.
anchoranychart.graphics.vector.Anchor | stringScaling anchor point.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

setPosition

Sets top left corner of a shape (transformation taken into account) in the coordinate system of the parent.
Note: See illustration at anychart.graphics.vector.Element#translate, the only difference between anychart.graphics.vector.Element#translate and this method is the fact that that this method resets the current transformation, and and anychart.graphics.vector.Element#translate adds movement to the existing transformation.

Params:

NameTypeDescription
xnumberX coordinate.
ynumberY coordinate.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

setRotation

Rotates a shape around the given point.
Note: See illustration at anychart.graphics.vector.Element#rotate, the only difference between anychart.graphics.vector.Element#rotate and this method is the fact that this method resets the current transformation, and anychart.graphics.vector.Element#rotate adds rotation to the existing transformation.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
cxnumberRotation point X.
cynumberRotation point Y.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

setRotationByAnchor

Rotates a shape around the given anchor.
Note: See illustration at anychart.graphics.vector.Element#rotateByAnchor, the only difference between anychart.graphics.vector.Element#rotateByAnchor and this method is the fact that this method resets the current transformation, and and anychart.graphics.vector.Element#rotate adds rotation to the existing transformation.

Params:

NameTypeDescription
degreesnumberRotation angle in degrees.
anchoranychart.graphics.vector.Anchor | stringRotation anchor.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

setTransformationMatrix

Sets transformation matrix.
Note: See illustration at anychart.graphics.vector.Element#appendTransformationMatrix, the difference between anychart.graphics.vector.Element#appendTransformationMatrix and this method is that anychart.graphics.vector.Element#appendTransformationMatrix combined transformation with the current, and this method resets the current.

Params:

NameTypeDescription
m00numberScale X.
m10numberShear Y.
m01numberShear X.
m11numberScale Y.
m02numberTranslate X.
m12numberTranslate Y.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

swapChildren

Swap children.

Params:

NameTypeDescription
element1anychart.graphics.vector.ElementFirst element.
element2anychart.graphics.vector.ElementSecond element.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

swapChildrenAt

Swap children by indices.

Params:

NameTypeDescription
index1numberFirst element index.
index2numberSecond element index.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

text

Invokes anychart.graphics.vector.Text class constructor.
Note:
anychart.graphics.vector.Layer does nothing to delete an object after it is used. You need to take care of used objects yourself.

Params:

NameTypeDescription
this{anychart.graphics.vector.Layer|anychart.graphics.vector.Stage}This param
xnumberX-coordinate (Left) of left top corner of text bounds.
ynumberY-coordinate (Top) of left top corner of text bounds.
textstringText to be displayed.
styleanychart.graphics.vector.TextStyleText style. More at anychart.graphics.vector.Text#style.

Returns:

anychart.graphics.vector.Text - An instance of class for method chaining.

translate

Moves a shape taking an account the current transformation. Movement happens in a shape coordinate system (not the coordinate system of the parent).

Params:

NameTypeDescription
txnumberX movement amount.
tynumberY movement amount.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

unlisten

Removes an event listener which was added with listen() or listenOnce().

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeSCOPEObject in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

visible

Gets/sets the current visibility flag.

Returns:

boolean - Returns the current visibility flag.
Hides or shows an element.

Params:

NameTypeDescription
isVisiblebooleanVisibility flag.

Returns:

anychart.graphics.vector.PatternFill - Self instance for method chaining.

zIndex

Gets and sets element's zIndex.

Params:

NameTypeDescription
valuenumberZ index to set.

Returns:

number | anychart.graphics.vector.PatternFill - Z index or itself for chaining.