Skip to content

AMElement

Type class

A base class for all SVG elements. Provides low-level DOM functionality.

All visual elements extend this class.

Sources

AMElement can be used (imported) via one of the following packages.

/**
* Import from: "core.ts"
* Use like: am4core.AMElement
*/
import * as am4core from "@amcharts/amcharts4/core";

Inheritance

AMElement does not extend any other symbol.

AMElement is extended by Group.

Properties

content

Type string

Element's SVG contents.

Returns element's contents as SVG markup.

node

Type SVGSVGElement

An SVG node of the element.

rotation

Type number

Element's rotation in degrees.

scale

Type number

Element's scale where 1 is original size.

Setting to 0.5 will reduce element's size by 50%, 2 will make element twice as large, etc.

textContent

Type string

Text contents of the SVG element.

x

Type number

Element's X position in pixels.

y

Type number

Element's Y position in pixels.

Methods

addClass(name: string)

Returns void

Adds a class to element.

addStyle(attributes: Object)

Returns AMElement

Adds style attributes to element's node.

attr(attributes: ISVGAttribute)

Returns AMElement

Sets a set of attributes on a element.

attrNS(ns: string,
attribute: string,
value: string
)

Returns AMElement

Sets a single attribute of the element's node using namesspace.

constructor(element: string | SVGSVGElement)

Returns AMElement

Constructor creates a new element or uses the one that was passed in.

dispose()

Returns void

Disposes element.

getAttr(attribute: string)

Returns string | null

Returns a value of a node attribute.

getAttrNS(ns: string,
attribute: string
)

Returns string

Returns a namespaced attribute value from node.

getBBox()

Returns IRectangle

Returns bounding box of the element.

ATTENTION: Bounding box calculations are extremely costly so should be used sparingly and cached whenever possible.

getStyle(attribute: string)

Returns string

Returns style attribute value.

isDisposed()

Returns boolean

Was this element already been disposed?

moveTo(point: IPoint)

Returns void

Moves the element to new coordinates.

removeAttr(attribute: string)

Returns void

Removes an attribute from element.

removeChildNodes()

Returns void

Removes all element's child nodes, basically leaving it empty.

removeClass(name: string)

Returns void

Removes a class from element.

removeNode()

Returns void

Removes element's node from DOM.

removeStyle(attribute: string)

Returns void

Removes style attribute from node.

setClass(name: string)

Returns void

Sets a class name on element.

Events

AMElement does not have any events.