class anychart.graphics.vector.Element Improve this Doc
Abstract class for all vector elements, such as groups and primitives.
Due to the fact that this class is a child of from goog.events.EventTarget
all its childs can work with events.
Never call a constructor directly!
Methods Overview
Events | |
listen() | Adds an event listener. |
listenOnce() | Adds an event listener that is removed automatically after the listener fired once. |
removeAllListeners() | Removes all listeners from this listenable. |
unlisten() | Removes an event listener which was added with listen() or listenOnce(). |
unlistenByKey() | Removes an event listener which was added with listen() by the key returned by listen(). |
Interactive | |
drag() | Dragging setting. |
Interactivity | |
visible() | Visibility flag |
Size and Position | |
appendTransformationMatrix() | Combines the transformation with the given transformation matrix. |
getAbsoluteBounds() | Gets element bounds in absolute coordinates (root element coordinate system). |
getAbsoluteHeight() | Returns height 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 the bounds. |
getHeight() | Returns the height. |
getRotationAngle() | Returns the rotation angle in degrees. |
getTransformationMatrix() | Returns the transformation matrix. |
getWidth() | Returns the width. |
getX() | Returns X in the coordinate system of the parent. |
getY() | Returns Y in the coordinate system of the parent. |
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 by anchor. 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() | Rotates a shape around the given point. |
setRotationByAnchor() | Rotates a shape around the given anchor. |
setTransformationMatrix() | Sets the transformation matrix. |
translate() | Moves a shape taking an account the transformation. |
zIndex() | Z-index setting. |
Miscellaneous | |
attr() | Attribute setting |
clip() | Clipping setting. |
cursor() | Cursor type. |
desc() | Description setting |
disablePointerEvents() | Pointer events setting. |
disableStrokeScaling() | Vector effect property |
dispose() | Disposes element completely. |
domElement() | Returns DOM element if element is rendered. |
getStage() | Stage object (to which the given element is bound). |
hasParent() | Whether parent element is set. |
id() | Element identifier |
parent() | Parent layer. |
remove() | Current element removes itself from the parent layer. |
title() | Title setting |
Methods Description
appendTransformationMatrix
Illustration shows a shape transformation with the several calls of
.appendTransformationMatrix(0, 0.5, 1, 0, 0, 0)
Params:
Name | Type | Description |
---|---|---|
m00 | number | Scale X. |
m10 | number | Shear Y. |
m01 | number | Shear X. |
m11 | number | Scale Y. |
m02 | number | Translate X. |
m12 | number | Translate Y. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
attr
Params:
Name | Type | Description |
---|---|---|
key | string | Name of attribute. |
Returns:
* - Attribute value.Try it:
Params:
Name | Type | Description |
---|---|---|
key | string | Name of attribute. |
value | * | Value of attribute. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
clip
Returns:
anychart.graphics.math.Rect - Returns rectangle settings.Attention! In SVG clip will transform according to transformation, and in VML clip will be surrounding.
Params:
Name | Type | Description |
---|---|---|
value | anychart.graphics.math.Rect | string | Clipping rectangle. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
cursor
Params:
Name | Type | Default | Description |
---|---|---|---|
value | anychart.graphics.vector.Cursor | null | Cursor type. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
desc
Returns:
string | null | undefined - The element description value.Try it:
Params:
Name | Type | Description |
---|---|---|
value | string | null | Value to set. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
disablePointerEvents
Params:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Pointer events property value. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
disableStrokeScaling
Returns:
boolean - The vector effect property.var element = stage.rect(10, 10, 100, 40); var disableStrokeScaling = element.disableStrokeScaling();
Learn more by link.
Params:
Name | Type | Default | Description |
---|---|---|---|
enabled | boolean | false | Vector effect property to set. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
dispose
Try it:
domElement
In case of Stage in Suspended state or unbound element - null is returned.
Returns:
Element - DOM element.drag
Returns:
boolean | anychart.graphics.math.Rect - Absolute element bounds or flag.Try it:
Params:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | anychart.graphics.math.Rect | false | Flag or a dragging area. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
getAbsoluteBounds
Returns:
anychart.graphics.math.Rect - Absolute element bounds.Try it:
getAbsoluteHeight
See illustrations at anychart.graphics.vector.Element#getAbsoluteWidth
Returns:
number - Height.Try it:
getAbsoluteWidth
getAbsoluteX
Returns:
number - Absolute X.Try it:
getAbsoluteY
Returns:
number - Absolute Y.Try it:
getBounds
getHeight
getRotationAngle
getStage
Returns:
anychart.graphics.vector.Stage - Stage object.Try it:
getTransformationMatrix
[
{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.Try it:
getWidth
getX
Returns:
number - X in the coordinate system of the parent.Try it:
getY
Returns:
number - Y in the coordinate system of the parent.Try it:
hasParent
id
Returns:
string - Returns element identifier.Try it:
Params:
Name | Type | Description |
---|---|---|
id | string | Custom identifier. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
listen
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function(e:Object):boolean|undefined | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
listenOnce
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function(e:Object):boolean|undefined | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
parent
Returns:
anychart.graphics.vector.Layer | anychart.graphics.vector.Stage - Instance of element current layer.Try it:
Params:
Name | Type | Description |
---|---|---|
parent | anychart.graphics.vector.Layer | anychart.graphics.vector.Stage | Parent layer. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
remove
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
removeAllListeners
Params:
Name | Type | Description |
---|---|---|
type | string | Type of event to remove, default is to remove all types. |
Returns:
number - Number of listeners removed.Try it:
rotate
Left illustration shows 20 degrees rotation with the default rotation point.
.rotate(20)
Right illustration shows 20 degrees rotation with the given rotation point.
.rotate(20, x, y)
Rotation points are marked with red, initial position of shapes is marked with gray.
Params:
Name | Type | Description |
---|---|---|
degrees | number | Rotation angle in degrees. |
cx | number | Rotation point X. |
cy | number | Rotation point Y. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
rotateByAnchor
Left illustration shows 90 degrees rotation around the default anchor.
.rotateByAnchor(90)
Right illustration shows 90 degrees rotation around the given anchor.
.rotateByAnchor(90, anychart.graphics.vector.Anchor.CENTER_TOP)
Rotation points are marked with red, initial position of shapes is marked with gray.
Params:
Name | Type | Description |
---|---|---|
degrees | number | Rotation angle in degrees. |
anchor | anychart.graphics.vector.Anchor | string | Rotation anchor. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
scale
Left illustration shows default point scaling.
.scale(0.5, 0.5,)
Right illustration shows scaling with the scaling center set.
.scale(0.5, 0.5, x, y)
Scaling center is marked with red, initial state is marked with gray.
Params:
Name | Type | Description |
---|---|---|
sx | number | X scaling factor. |
sy | number | Y scaling factor. |
cx | number | Scaling point X. |
cy | number | Scaling point Y. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
scaleByAnchor
Left illustration shows scaling with the default anchor.
.scaleByAnchor(0.5, 0.5)
Right illustration shows scaling with the anchor set.
.scaleByAnchor(0.5, 0.5, anychart.graphics.vector.Anchor.RIGHT_TOP)
Scaling center is marked with red, initial state is marked with gray.
Params:
Name | Type | Description |
---|---|---|
sx | number | X scaling factor. |
sy | number | Y scaling factor. |
anchor | anychart.graphics.vector.Anchor | string | Scaling anchor point. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
setPosition
Params:
Name | Type | Description |
---|---|---|
x | number | X coordinate. |
y | number | Y coordinate. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
setRotation
Params:
Name | Type | Description |
---|---|---|
degrees | number | Rotation angle in degrees. |
cx | number | Rotation point X. |
cy | number | Rotation point Y. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
setRotationByAnchor
Params:
Name | Type | Description |
---|---|---|
degrees | number | Rotation angle in degrees. |
anchor | anychart.graphics.vector.Anchor | string | Rotation anchor. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
setTransformationMatrix
Params:
Name | Type | Description |
---|---|---|
m00 | number | Scale X. |
m10 | number | Shear Y. |
m01 | number | Shear X. |
m11 | number | Scale Y. |
m02 | number | Translate X. |
m12 | number | Translate Y. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
title
Returns:
string | null | undefined - The element title value.Try it:
Params:
Name | Type | Description |
---|---|---|
value | string | null | Value to set. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
translate
Illustration shows a shape movement when
.translate(20, 10)
is invoked several times.Params:
Name | Type | Description |
---|---|---|
tx | number | X movement amount. |
ty | number | Y movement amount. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
unlisten
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function(e:Object):boolean|undefined | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
boolean - Whether any listener was removed.Try it:
unlistenByKey
Params:
Name | Type | Description |
---|---|---|
key | Object | The key returned by listen() or listenOnce(). |
Returns:
boolean - Whether any listener was removed.Try it:
visible
Params:
Name | Type | Default | Description |
---|---|---|---|
isVisible | boolean | true | Visibility flag. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it:
zIndex
Params:
Name | Type | Description |
---|---|---|
value | number | Z-index to set. |
Returns:
anychart.graphics.vector.Element - Self instance for method chaining.Try it: