API Docs for: 3.5.1
Show:

SVGGraphic Class

SVG implementation of the Graphic class. SVGGraphic is not intended to be used directly. Instead, use the Graphic class. If the browser has SVG capabilities, the Graphic class will point to the SVGGraphic class.

Methods

_appendShape

(
  • shape
)
private

Adds a shape instance to the graphic instance.

Parameters:

  • shape Shape

    The shape instance to be added to the graphic.

_createGraphicNode

(
  • type
  • pe
)
private

Creates a graphic node

Parameters:

  • type String

    node type to create

  • pe String

    specified pointer-events value

Returns:

HTMLElement

_createGraphics

() private

Creates a contentNode element

_getDocFrag

() private

Returns a document fragment to for attaching shapes.

Returns:

DocumentFragment

_getShapeClass

(
  • val
)
private

Returns a shape class. Used by addShape.

Parameters:

Returns:

Function

_getUpdatedContentBounds

() Object private

Recalculates and returns the contentBounds for the Graphic instance.

Returns:

_redraw

() private

Redraws all shapes.

_removeChildren

(
  • node
)
private

Removes all child nodes.

Parameters:

_toggleVisible

(
  • val
)
private

Toggles visibility

Parameters:

  • val Boolean

    indicates visibilitye

addShape

(
  • cfg
)

Generates a shape instance by type.

Parameters:

  • cfg Object

    attributes for the shape

Returns:

Shape

addToRedrawQueue

(
  • shape
)
protected

Adds a shape to the redraw queue and calculates the contentBounds. Used internally by Shape instances.

Parameters:

batch

(
  • method
)

Allows for creating multiple shapes in order to batch appending and redraw operations.

Parameters:

clear

()

Clears the graphics object.

destroy

()

Removes all nodes.

getGradientNode

(
  • key
  • type
)
protected

Returns a reference to a gradient definition based on an id and type.

Parameters:

  • key String

    id that references the gradient definition

  • type String

    description of the gradient type

Returns:

HTMLElement

getShapeById

(
  • id
)

Returns a shape based on the id of its dom node.

Parameters:

  • id String

    Dom id of the shape's node attribute.

Returns:

Shape

getXY

()

Gets the current position of the graphic instance in page coordinates.

Returns:

Array The XY position of the shape.

initializer

() private

Initializes the class.

removeAllShapes

()

Removes all shape instances from the dom.

removeShape

(
  • shape
)

Removes a shape instance from from the graphic instance.

Parameters:

  • shape Shape | String

    The instance or id of the shape to be removed.

render

(
  • parentNode
)

Adds the graphics node to the dom.

Parameters:

  • parentNode HTMLElement

    node in which to render the graphics node into.

Properties

_resizeDown

Boolean private

_shapeClass

Object private

Look up for shape classes. Used by addShape to retrieve a class for instantiation.

_x

Number private

Storage for x attribute.

_y

Number private

Storage for y attribute.

Attributes

autoDraw

Boolean private

Indicates whether or not the instance will automatically redraw after a change is made to a shape. This property will get set to false when batching operations.

Default: true

autoSize

Boolean

Determines how the size of instance is calculated. If true, the width and height are determined by the size of the contents. If false, the width and height values are either explicitly set or determined by the size of the parent node's dimensions.

Default: false

contentBounds

Object

Object containing size and coordinate data for the content of a Graphic in relation to the coordSpace node.

height

Number

Indicates the height of the Graphic.

id

String

Unique id for class instance.

node

HTMLElement

The html element that represents to coordinate system of the Graphic instance.

render

Node | String

Whether or not to render the Graphic automatically after to a specified parent node after init. This can be a Node instance or a CSS selector string.

resizeDown

Boolean

The contentBounds will resize to greater values but not to smaller values. (for performance) When resizing the contentBounds down is desirable, set the resizeDown value to true.

shapes

Object

Key value pairs in which a shape instance is associated with its id.

width

Number

Indicates the width of the Graphic.

x

Number

Indicates the x-coordinate for the instance.

y

Number

Indicates the y-coordinate for the instance.