New to KendoReact? Start a free 30-day trial

Shape

Class

Definition

Package:@progress/kendo-react-diagram

Properties

The adorner used for visual feedback during interactions.

Array of connectors attached to this shape.

The data item associated with this diagram element.

events

string[]

Array of event names that this observable supports.

id

string

The unique identifier of this diagram element.

isSelected

boolean

Indicates whether this element is currently selected.

Configuration options for the observable instance.

The visual representation of the shape.

The type of the shape (e.g., 'rectangle', 'circle', 'text', etc.) or FlowchartShapeTypes.Extract.

The visual representation (Group) of this diagram element.

Methods

Binds event handlers to one or more events.

Parameters:eventEventNames | { [key: string]: Handler }

The event name(s) to bind to, or an object mapping event names to handlers

handlers?EventHandlers

The event handler(s) to bind. Can be a function or an object mapping event names to handlers

one?boolean

If true, the handler will be executed only once and then automatically unbound

Returns:

this

The Observable instance for method chaining

Gets the shape bounds in model coordinates.

Returns:

Rect

The shape bounds in model coordinates.

Gets the shape bounds using the specified coordinate representation.

Parameters:kindShapeBoundsKind

The bounds representation to retrieve.

Returns:

Rect

The shape bounds in the specified coordinate representation.

Sets the shape bounds.

Parameters:valueRect

The new shape bounds.

Returns a clone of this shape.

Returns:

Shape

A new Shape instance that is a copy of this shape

Gets connections of this shape based on type.

Parameters:type?"in" | "out"

The type of connections to retrieve: 'in' for incoming, 'out' for outgoing, or undefined for all connections.

Returns:

Connection[]

Array of connections

Gets the current content of the shape.

Returns:

ShapeContent | ShapeRichTextContent

The current shape content.

Sets the content of the shape.

Parameters:contentShapeContent | ShapeRichTextContent

The new shape content.

Returns:

ShapeContent | ShapeRichTextContent

The applied shape content.

Creates the visual representation of the shape based on its type and options. Supports custom templates, predefined shapes (rectangle, circle, text, image), and custom paths.

Destroys the observable instance and removes all event handlers. This method should be called when the observable is no longer needed to prevent memory leaks.

Binds event handlers to be executed first (prepends to the handlers list). These handlers will be called before any previously bound handlers for the same event.

Parameters:eventNameEventNames

The event name(s) to bind to

handlersEventHandlers

The event handler(s) to bind

Returns:

this

The Observable instance for method chaining

Gets a connector of this shape either by the connector's supposed name or via a Point in which case the closest connector will be returned.

Parameters:nameOrPoint?string | Point

The name of a Connector or a Point.

Returns:

undefined | null | Connector

The matching connector, the closest connector, the first connector when no argument is passed, or null/undefined when none is available

Gets the position of the shape at a specific side.

Parameters:sidestring

The side to get position for (e.g., 'top', 'bottom', 'left', 'right', 'center')

Returns:

Point

The position point at the specified side

Binds event handlers that will be executed only once. After execution, the handlers are automatically unbound.

Parameters:eventNamesEventNames

The event name(s) to bind to

handlersEventHandlers

The event handler(s) to bind

Returns:

this

The Observable instance for method chaining

Gets the current position of the shape.

Returns:

Point

The current shape position.

Sets the position of the shape.

Parameters:pointPointLike

The new shape position.

Redraws the shape with new options.

Parameters:options?Partial​<ShapeOptionsBase>

The options to apply when redrawing the shape

Redraws the shape's visual representation. Updates both the visual and content if present.

Refreshes the visual representation of the diagram element. Triggers a redraw of the visual component.

Refreshes all connections attached to this shape. Updates the visual representation of all connected connections.

Gets the current rotation of the shape.

Returns:

Rotation

The current rotation transform.

Rotates the shape by the specified angle.

Parameters:anglenumber

The rotation angle in degrees.

center?Point

The center point for rotation. Defaults to the shape center.

undoable?boolean

Whether the rotation can be undone. Defaults to true.

Returns:

Rotation

The rotation transform before the update.

Selects or deselects the shape.

Parameters:value?boolean

Whether to select (true) or deselect (false) the shape. If not provided, defaults to true.

Returns:

undefined | boolean

True if the selection state changed; otherwise undefined.

Serializes the diagram element to a JSON object.

Returns:

{ options: any; dataItem?: string }

The element options and optional data item identifier.

Converts the shape to a JSON representation for serialization.

Returns:

{ shapeId: string }

Object containing the shape's ID

Returns a string representation of the diagram element.

Returns:

string

The element ID.

Triggers an event, calling all bound handlers for that event.

Parameters:eventNamestring

The name of the event to trigger

eventArgs?any

Optional event arguments to pass to the handlers

Returns:

boolean

True if any handler called preventDefault(), false otherwise

Removes event handlers from events.

Parameters:eventName?string

The event name to unbind from. If undefined, all events are unbound

handler?EventHandlers

The specific handler to remove. If undefined, all handlers for the event are removed

Returns:

this

The Observable instance for method chaining

Updates the shape's bounds based on its visual representation and handles rotation and content alignment.

Updates the shape options from the model data.

Parameters:model?any

The model data to extract options from

field?string

Specific field to update, if any

Gets the visibility of the diagram element.

Returns:

boolean

true when the element is visible; otherwise, false.

Sets the visibility of the diagram element.

Parameters:valueboolean

Whether the element should be visible.