C

GraphComponent

A component for displaying and editing an IGraph.
ImplementsInheritance Hierarchy

Remarks

This is a specialized CanvasComponent that can hold, display, and edit an IGraph instance. It provides access to the graph and selection instances.

This class suppports the following Commands.

The ZOOM_TO_CURRENT_ITEM is enabled, if navigationCommandsEnabled is true.

By default, this class sets a plain GraphViewerInputMode as the inputMode to enable basic exploratory interaction with the graph. To enable interactive editing, use a GraphEditorInputMode, instead.

See Also

The components that can be used to display and edit a model are discussed in the section The Component for Displaying Graphs.

Developer's Guide

Demos

Displays sample graphs from various application domains.
Shows the graph editing features of the graph component.
Introduces the GraphComponent class, the central UI element for working with graphs.

Members

Show:

Constructors

Creates a new instance of the GraphComponent.
If the graph and selection properties are not populated externally they will be initialized with default values upon first access. Thus, this instance can be used right away without any further initialization. This constructor creates a new htmlElement that needs to be manually added to the DOM.

Parameters

Creates a new instance of the GraphComponent in the provided htmlElement.

If the graph and selection properties are not populated externally, they will be initialized with default values upon first access. Thus, this instance can be used right away without any further initialization.

All child nodes of the htmlElement are added to the overlayPanel.

Parameters

htmlElement: HTMLElement
The existing HTMLElement to use for rendering the canvas into. All its child nodes are added to the overlayPanel.

Throws

Exception ({ name: 'ArgumentError' })
if the htmlElement is already used by another component.
Creates a new instance of GraphComponent using the HTMLElement that is specified by the selector.

If the graph and selection properties are not populated externally they will be initialized with default values upon first access. Thus this instance can be used right away without any further initialization.

All child nodes of the HTMLElement are added to the overlayPanel.

Parameters

selector: string
The CSS selector or id for an existing HTMLElement. All child nodes of this element are added to the overlayPanel.

Throws

Exception ({ name: 'ArgumentError' })
if the HTMLElement specified by the selector is already used by another component.

Properties

Gets or sets a combination of viewport changes that should be performed in an animated fashion.
conversionfinal

Property Value

A combination of ViewportChanges values that specifies which viewport changes should be animated.

Examples

Animating only mouse-wheel zoom and zoom commands
graphComponent.animatedViewportChanges =
  ViewportChanges.MOUSE_WHEEL_ZOOM | ViewportChanges.ZOOM_COMMAND

See Also

Developer's Guide
API
getViewportAnimationDuration
Gets the aria-live region of the CanvasComponent.

Elements appended to this region are read by screen readers.

The live region is initialized with aria-live="polite" and aria-atomic="false" and added to the DOM upon first access.

readonlyfinal
Gets or sets a property that causes the control to automatically pan the view when the mouse is dragged outside the bounds of the control.
Gets or sets the distance from the edge of the viewport, in which auto-scrolling should happen.

If the mouse is being dragged within the padding of the control specified using this property, the control will automatically scroll.

The default is (10,10,10,10)

conversionfinal

Property Value

The new auto-scroll padding.

See Also

API
autoScrollOnBounds
Gets an implementation of ICanvasContext that describes the state of this CanvasComponent.
Gets or sets a value indicating whether all keyboard input is captured.
final

Property Value

true if all keyboard input is captured; otherwise, false.
Gets or sets a value indicating whether all pointer input is captured.
final

Property Value

true if all pointer input is captured; otherwise, false.
Gets or sets the world coordinate at the center of the control.
Setting this property moves the viewport, similarly to viewPoint. It will not change the zoom level.
conversionfinal

Examples

Setting a new center point for the viewport
console.log(
  `Current center: ${graphComponent.center} , and view point: ${graphComponent.viewPoint}`,
)
graphComponent.center = new Point(150, 50)
console.log(`New center is: ${graphComponent.center}`)
console.log(
  `The view point has also changed: ${graphComponent.viewPoint}`,
)

See Also

API
viewPoint, zoomTo, zoomToAnimated
Gets or sets an event recognizer that determines whether zooming with the mouse wheel should zoom to the center of the view instead of the mouse location.
The default is ALT_IS_DOWN, since by default shift will trigger horizontal panning and ctrl will trigger vertical panning.
final

Examples

Changing the recognizer to use Shift to zoom to the viewport center
graphComponent.centerZoomEventRecognizer = EventRecognizers.SHIFT_IS_DOWN
Always zoom to the mouse location
graphComponent.centerZoomEventRecognizer = EventRecognizers.NEVER

See Also

Developer's Guide
Gets or sets the GraphClipboard associated with this control.
If no instance has been configured with this control, a default implementation will be used.
final

See Also

Developer's Guide
Gets and sets the rectangle in world coordinates that holds the contents.
This influences the display of the scroll bars. If the content bounds are not currently visible in the viewport, scroll bars will be displayed, unless they are turned off completely. Note that in general, the content bounds are not updated automatically but declared as a fixed rectangle. Rather, the application programmer needs to set this value or call the respective automatic update methods.
conversionfinal

See Also

Developer's Guide
Gets and sets the margins in view coordinates that should be used by the fitContent operation or zoom commands which zoom to a given rectangle.

This influences the amount of visible whitespace in the view coordinate system around the contentBounds after a fitContent operation. The default value is (10,10,10,10).

For the ZOOM_TO_CURRENT_ITEM on a GraphComponent, the margins define the visible whitespace around the rectangle in which the respective item is centered. This way it is also possible to get asymmetric whitespace around the item. The same applies to the ZOOM command with a Rect, IBoundsProvider, or an ILookup returning an IBoundsProvider as parameter.

Note limits that are enforced by the viewportLimiter have a higher priority than these margins.

The default is (10,10,10,10)

conversionfinal

See Also

Developer's Guide
Gets or sets the currently focused item.

The focused item is shown with a faint dotted border by default.

This is a concept related to selection. The main difference is that there can be at most one focused item, while multiple items can be selected at once.

final

Property Value

The current item by default is given focus indication using the focusIndicatorManager.

Sample Graphs

ShownSetting: Visual difference between a focused and a selected node

See Also

Developer's Guide
Gets or sets the scaling factor for WebGL and Canvas rendering.
Set this value to window.devicePixelRatio for crisp rendering on high DPI devices.
final
Gets or sets the value of the double-click time.
This value indicates the amount of time that may pass within which two subsequent pointer clicks are considered multi-clicks. The higher the value the easier it will be to double-click. The default value is 500 milliseconds.
conversionfinal
Gets the dropTarget associated with this instance.
readonlyfinal

Property Value

The instance that is responsible for handling drop operations.
Gets a value indicating whether this CanvasComponent is currently focused.
readonlyfinal

Property Value

true if focused; otherwise, false.
Gets or sets the FocusIndicatorManager<T> that manages display of the focus indicator for keyboard operations.
Gets or sets the graph that is displayed in this control.

Some IInputModes (notably GraphViewerInputMode and GraphEditorInputMode) may retain references to items in the old graph until certain interactions, so it sometimes can be a good idea to re-create and replace the input mode when changing to graph so the old graph reference is eligible for garbage collection.

When changing the graph to one that uses the same IModelItem instances as the old one (e.g. when using FilteredGraphWrapper), the current selection is retained.

final

See Also

Developer's Guide
Gets or sets the graphModelManager property.
Setting a new value to this property will install the new GraphModelManager and uninstall the old one.
final
Gets a value indicating whether this instance currently has mouse capture.
protectedreadonlyfinal

Property Value

true if this instance has mouse capture; otherwise, false.
Gets or sets the HighlightIndicatorManager<T> which is responsible for rendering the highlights.
final

Examples

The following example shows how to highlight items:
// Add a highlight
graphComponent.highlightIndicatorManager.items?.add(node)

// Determine whether an item is highlighted
graphComponent.highlightIndicatorManager.items?.includes(node)

// Remove it again
graphComponent.highlightIndicatorManager.items?.remove(node)

// Clear all highlights
graphComponent.highlightIndicatorManager.items?.clear()

See Also

Developer's Guide
Gets or sets the collection model that stores the highlight state for the visualization.

The default implementation allows for highlighting elements that are not part of the graph and will thus not automatically clear the highlight of an element that gets removed from the graph.

A concept related to highlighting is selection and the currentItem, which represent the currently focused item. This is also shown in a selection- or highlight-like fashion.

final

Examples

The highlighted elements can be either queried for or manipulated to highlight items programmatically. The following example shows a few things that can be done:
// Add a highlight
graphComponent.highlights.add(node)

// Determine whether an item is highlighted
const highlighted = graphComponent.highlights.includes(node)

// Remove the highlighting
graphComponent.highlights.remove(node)

// check whether there are any highlights
const anyHighlights = graphComponent.highlights.size > 0

// Iterate all highlighted items
graphComponent.highlights.forEach((highlightedItem) => {
  // ...
})

// Clear all highlights
graphComponent.highlights.clear()

// listen to low-level changes in the selection
graphComponent.highlights.addEventListener('item-added', (args) => {
  console.log(`Highlighted ${args.item}`)
})
graphComponent.highlights.addEventListener('item-removed', (args) => {
  console.log(`Removed highlight from ${args.item}`)
})

See Also

Developer's Guide
API
selection
Gets or sets the radius of the area around the pointer in view coordinates in which an IHitTestable may lie to be considered a valid hit.

This value converted into world coordinates can be queried from within the IHitTestable implementation from the hitTestRadius property, which automatically takes the zoom level into account. Note that the context's property automatically switches between the value for mouse, touch, and stylus, based on the last input event.

The default value is 3 for MOUSE, 6 for PEN, and 12 for TOUCH.

final

See Also

Developer's Guide
Gets or sets the visibility policy for the horizontal scrollbar.
Scrollbars don't need to be displayed in order to move the viewport. This can be achieved programmatically or using special IInputMode instances. The default is AUTO.
conversion

See Also

Developer's Guide
API
MoveViewportInputMode, verticalScrollBarPolicy
Gets or sets an event recognizer that determines whether the mouse wheel should scroll in horizontal instead of vertical direction.

This recognizer is only used if mouseWheelBehavior has the SCROLL flag.

The default is SHIFT_IS_DOWN.

final

Examples

Changing the recognizer to use Ctrl for horizontal scrolling
graphComponent.horizontalScrollEventRecognizer =
  EventRecognizers.CTRL_DOWN
Gets the HTMLElement that represents this instance.
readonlyfinal
Gets or sets the image-rendering type for this visual and its children.
Image rendering can improve performance but affects the display quality of images.
conversionfinal
Gets the size of the usable area in which the graph will be displayed.
This value excludes the scroll bars.
readonlyfinal
Gets or sets the single IInputMode instance that shall be installed for this canvas.
final

Examples

Installing a GraphEditorInputMode
graphComponent.inputMode = new GraphEditorInputMode()
Installing a GraphViewerInputMode
// set a new instance - by default, a GraphViewerInputMode is already set
graphComponent.inputMode = new GraphViewerInputMode()

See Also

Developer's Guide
Gets or sets the IInputModeContext instance that is used by the inputMode instance.
Gets the last location provided by a pointing device (for instance mouse or touch).
This will contain the latest location, regardless of what input method generated it.
readonlyfinal
Gets the last pointer event triggered by this instance.
readonlyfinal

See Also

API
pointer-click
Gets or sets a value indicating whether the maximum zoom level for fitContent and FIT_CONTENT is limited to 1.

If this property is true, fitContent and FIT_CONTENT will limit the maximum zoom level to 1. This can lead to very small graphs not filling the viewport. If this property is set to false, zooming will only be limited by maximumZoom.

The default value is true.

final
Gets or sets the duration a pointing device must be held down without moving before the pointer-long-press event is raised.

Small pointer moves are ignored, so jittery pointer types like PEN or TOUCH will not block the event.

The default value is 250 milliseconds.

If you are listening for the context-menu event, we recommend lowering this value to, for exammple, 100ms because handling the context-menu event will stop other input modes from acting on the subsequent long-press event (e.g., edge creation). Therefore, lowering the longPressTime will extend the time frame between the long-press and the context-menu event.
conversionfinal

See Also

API
pointer-long-press, longRestTime
Gets or sets the duration a pointing device must not move before the pointer-long-rest event is raised.

Small pointer moves are ignored, so jittery pointer types like PEN or TOUCH will not block the event.

The default value is 750 milliseconds.

conversionfinal

See Also

API
pointer-long-rest, longPressTime
Gets or sets the maximum zoom factor for this CanvasComponent.
This property sets an upper bound for the allowed values of the zoom property. The default is 100000.0 and the enforced maximum value is 1000000.0.
final

Examples

Ensuring that the zoom level cannot go above 400 %
graphComponent.maximumZoom = 4

See Also

Developer's Guide
Gets or sets the minimum zoom factor for this CanvasComponent.
This property sets a lower bound for the allowed values of the zoom property. If this property is written, the canvas will zoom to the new value while keeping the center of view at the same world coordinates. The default value is 0.0001, the enforced minimum 0.0000001.
final

Examples

Ensuring that the zoom level cannot go below 100 %
graphComponent.minimumZoom = 1

See Also

Developer's Guide
API
zoom, maximumZoom
Gets or sets a value that specifies whether this control receives mouse input after the mouse is dragged out of its bounding area.
If enabled, this control receives mouse events when the mouse is moved out of its bounding area while a mouse button is pressed, until the button is release (the mouse up event is the last event this control listens to).
final
Gets or sets the action to perform when turning the mouse wheel.

Valid values for this property are as follows:

  • NONE – No action is being taken when turning the mouse wheel.
  • ZOOM – The zoom level of the viewport is adjusted when turning the mouse wheel or pinching on a touchpad.
  • SCROLL – The viewport is scrolled vertically when turning the mouse wheel, and horizontally when turning the mouse wheel while pressing the Shift key. No modifier key is required if bidirectional wheel events are available (e.g. touchpad or two-axis mouse wheel).
  • SCROLL, ZOOM – Both SCROLL and ZOOM can be combined to allow both scrolling and zooming. The default action without any modifiers pressed is zooming. Pressing the Shift key while turning the mouse wheel will scroll horizontally while pressing the Control key will result in vertically scrolling. This is the default.
  • Any of the above options, except for NONE can be combined with ONLY_WHEN_FOCUSED to allow the interaction only when the CanvasComponent is focused.

The mouseWheelBehavior can be omitted by calling preventDefault on the event args of the wheel event.

conversionfinal

Examples

Changing what turning the mouse wheel does
// The mouse wheel should be used for scrolling.
graphComponent.mouseWheelBehavior = MouseWheelBehaviors.SCROLL
// The mouse wheel can be used either for scrolling or zooming, depending on the modifiers
// but only when the control is focused.
graphComponent.mouseWheelBehavior =
  MouseWheelBehaviors.SCROLL |
  MouseWheelBehaviors.ZOOM |
  MouseWheelBehaviors.ONLY_WHEN_FOCUSED

See Also

Developer's Guide
Gets or sets a factor that controls how fast the viewport scrolls when the mouse wheel is turned.

Scrolling can work either a few lines at a time (per notch of the scroll wheel) or one page at a time. This is a system setting. This property controls how many pixels represent a line if scrolling is done by line. In case scrolling is done by page, this property has no effect.

The default value is 25 pixels. To speed up scrolling, set a larger value, to slow down scrolling, set a smaller value. Set negative values to invert the scrolling/panning behavior, e.g., for trackpads.

final

See Also

Developer's Guide
API
mouseWheelZoomFactor, mouseWheelBehavior
Gets or sets an event recognizer that determines whether turning the mouse wheel should perform zooming instead of scrolling.

This recognizer is only used if mouseWheelBehavior has both the SCROLL and ZOOM flags.

The default implementation detects whether ctrl or shift have been pressed separately or a precision trackpad is used for panning. In these cases, false will be returned, enabling zooming with the mouse both via scroll wheels and pinch zooming via trackpads.

final

Examples

Changing the recognizer to use Alt to zoom
graphComponent.mouseWheelZoomEventRecognizer =
  EventRecognizers.ALT_IS_DOWN

See Also

Developer's Guide
Gets or sets the factor by which the zoom level changes when the mouse wheel is turned.
Gets or sets a value indicating whether navigation related command bindings are enabled.

By default this feature is enabled.

This property enables/disables the following commands:

final

Property Value

true if the commands are enabled; otherwise, false.

Examples

Disabling the navigation commands in code
graphComponent.navigationCommandsEnabled = false
Gets or sets an event recognizer that temporarily enables mouse wheel events.

If ONLY_WHEN_FOCUSED is set but this CanvasComponent is currently not focused, events accepted by this recognizer will force this CanvasComponent to handle the mouse wheel events anyways.

The default is NEVER. A common use case is to set this recognizer to accept modifier keys such as CTRL_IS_DOWN.

final
Returns an HTML element that can be used to show arbitrary HTML content like overlays, fly-outs, or pop-ups on top of this CanvasComponent.

An HTML element that was added to the overlay panel is drawn above the content of this CanvasComponent but below its scrollbars. In contrast to labels or other model items, this element keeps its size when the canvas is zoomed. It should be placed with the CSS property position: absolute to prevent multiple overlay elements to interfere with each other.

If a container element is passed to the constructor of this CanvasComponent, all its child nodes are passed to this overlay panel. Apart from that, content may be added to and removed from this panel at any time.

readonlyfinal
Gets or sets a Matrix that is applied to the viewport.
The Matrix must not have a translation component.
final

See Also

Developer's Guide
Gets or sets a value indicating whether input coordinates (mouse and touch) should be quantized depending on the zoom level to give nicer values.

By default, the coordinates of input events are translated directly to world coordinates, which, with many zoom levels can end up with world coordinates like 326.76821937283548; this excessive precision is an artifact of the fact that every viewport pixel covers a fractional amount of world coordinates.

This option quantizes the coordinates depending on the zoom level so that above value may end up, e.g. as 326.75 instead. This is done in a way to minimize visual deviation from the exact value (much less than a pixel), so visually almost nothing changes. Zooming in will increase the precision as much as necessary, but not so far to be excessive. The benefit is that coordinates are easier to recognize in a debugger, graph elements end up with locations that are easier to read, GraphML files become smaller because less space is wasted on unnecessary floating point precision, and numerical instability in certain cases (e.g. some snapping scenarios) is eliminated.

The default value is true.

final
Gets the render tree for the canvas that holds all IRenderTreeElements that will be rendered by this instance.
Gets a value indicating whether the UI is right to left.
The value is fetched and cached on first access and the cache gets invalidated when the size of the component has changed. This is to avoid costly queries into the CSS engine.
readonlyfinal

Property Value

true if the main UI direction is right to left; otherwise, false.
Gets or sets the selection model that stores the selection state for the visualization.

The selection model instance needs to be adjusted, typically when the graph instance is changed.

A concept related to selection is the currentItem, which represents the currently focused item. This is also shown in a selection-like fashion.

final

Examples

The selection can be either queried for selected items or manipulated to select or deselect items programmatically. The following example shows a few things that can be done:
// Determine whether an item is selected
let selected = graphComponent.selection.includes(node)
// alternatively, if you know the type:
selected = graphComponent.selection.nodes.includes(node)

// Deselect an edge
graphComponent.selection.remove(edge)

// check whether the selection is empty
const isEmpty = graphComponent.selection.size === 0

// Iterate over selected nodes
for (const n of graphComponent.selection.nodes) {
  // ...
}

// Iterate all selected items
graphComponent.selection.forEach((selection) => {
  // ...
})

// Unselect all edges
graphComponent.selection.edges.clear()

// clear the whole selection
graphComponent.selection.clear()

// select all nodes
graphComponent.graph.nodes.forEach((n) => {
  graphComponent.selection.nodes.add(n)
})

// listen to low-level changes in the selection
graphComponent.selection.addEventListener('item-added', (args) => {
  console.log(`Selected ${args.item}`)
})
graphComponent.selection.addEventListener('item-removed', (args) => {
  console.log(`Deselected ${args.item}`)
})

Sample Graphs

ShownSetting: Visual difference between a focused and a selected node

See Also

Developer's Guide
API
currentItem, highlights
Gets or sets the selectionIndicatorManager property.
Gets or sets the shape-rendering type for this visual and its children.
Shape rendering can improve performance but affects the display quality of this visual.
conversionfinal
Returns the size of the HTML element.
readonlyfinal
Gets the control's svgDefsManager
readonlyfinal
Gets or sets the visibility policy for the vertical scrollbar.
Scrollbars don't need to be displayed in order to move the viewport. This can be achieved programmatically or using special IInputMode instances. The default is AUTO.
conversion

See Also

Developer's Guide
API
MoveViewportInputMode, horizontalScrollBarPolicy
Gets or sets the current viewpoint.
The viewpoint is the point in world coordinates that is mapped to the top left corner point in the current viewport. Setting this point to another value will redispatch the last pointer event as the mouse will appear to have been moved or dragged in the world coordinate system.
conversionfinal

Examples

Setting a new value for the ViewPoint property
console.log(
  `Current view point: ${graphComponent.viewPoint} , and center: ${graphComponent.center}`,
)
graphComponent.viewPoint = new Point(150, 50)
console.log(`New view point is: ${graphComponent.viewPoint}`)
console.log(`The center has also changed: ${graphComponent.center}`)

See Also

Developer's Guide
Gets the smallest rectangle in world coordinates that encompasses the visible viewing region.
Gets or sets the ViewportLimiter instance that can be used to limit the explorable region.

By default, there are no limits set on the explorable region.

When a projection is set, the viewportLimiter is ignored.

final

See Also

Developer's Guide
Gets or sets the policy for caching Visuals which are temporarily removed from the visual tree.

Visuals are temporarily removed when they are moved outside the visual part of the canvas (the viewport ) and re-added when they enter the viewport again. Caching prevents the need to re-build the visuals from scratch.

Visuals are only cached if this property is set to other value than NEVER and if a dispose visual callback is registered during creation.

If the visual is using the ISvgDefsCreator, the visual additionally needs to check in updateVisual whether the defs element is still in the DOM. The ISvgDefsCreator may have removed the defs element in the meantime if it was unused.
conversionfinal
Gets or sets the zoom factor for this CanvasComponent.

A zoom level of 1.0 will make each unit in world-coordinate space appear exactly one unit in screen coordinates wide. The default is 1.0. When setting this property to change the zoom level, the center point will remain the same.

The valid range is bounded by minimumZoom and maximumZoom

final

Examples

Resetting the zoom level to 100%
console.log(
  `Resetting the zoom level from ${graphComponent.zoom} to 100 %.`,
)
graphComponent.zoom = 1

See Also

Developer's Guide
API
zoom-changed, minimumZoom, maximumZoom, zoomTo, zoomToAnimated

Methods

Runs a layout on the graph of the GraphComponent and animates the transition.
The implementation simply delegates to a properly configured instance of LayoutExecutor. In addition to the default configuration, it enables animateViewport, easedAnimation, and updateContentBounds. For more fine-grained control of the animation, use LayoutExecutor directly.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

layout: ILayoutAlgorithm
The layout to run.
animationDuration?: TimeSpan
The duration of the animation. The default value is 0.5 seconds.
layoutData?: LayoutData<INode, IEdge, ILabel, ILabel>
The layout data to apply.
stopDuration?: TimeSpan
the maximum runtime for the layout calculation before it is automatically stopped.
cancelDuration?: TimeSpan
the maximum runtime for the layout calculation before it is automatically canceled.
animateViewport?: boolean
A value indicating whether the viewport should be animated to the new bounds of the graph.
portAdjustmentPolicies?: ItemMapping<IPort, PortAdjustmentPolicy>
The policy that specifies how port locations should be adjusted after a layout has been calculated.
portPlacementPolicies?: ItemMapping<IPort, PortPlacementPolicy>
The policy that specifies how ports should be placed by the layout algorithm.
portLabelPolicies?: ItemMapping<ILabel, PortLabelPolicy>
Sets how ILabels at IPorts should be treated by the layout algorithm.
anchoredItems?: ItemMapping<IModelItem, LayoutAnchoringPolicy>
Specifies which part of the items should be used to anchor the graph during layout.
targetBoundsPadding?: Insets
The insets (in world coordinates) that will be added to the content rectangle when calculating the target viewport.
labelPlacementPolicies?: ItemMapping<ILabel, LabelPlacementPolicy>
Sets how ILabels should be placed by the layout algorithm.
nodeComparator?: function(INode, INode): number
A comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations.
edgeComparator?: function(IEdge, IEdge): number
A comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations.

Return Value

Promise<void>
A Promise<void> that will resolve once the layout animation is finished.

See Also

Developer's Guide
API
LayoutExecutor, applyLayout, ensure
Returns whether the given command can be executed with the given optional parameter.

See the documentation of the Command which parameter can be used with the given command.

It is strongly advised to query this method before calling executeCommand.

Some commands can only be executed if a GraphViewerInputMode or GraphEditorInputMode is installed.

final

Parameters

command: Command
The command to execute.
parameter?: any
An optional parameter to provide for the command.

Return Value

boolean
Returns true if the command can be executed, otherwise false.

See Also

API
Command, addCommandBinding
Cleans up by removing any connection from the htmlElement element to the GraphComponent instance and any associated element that was created during the lifetime of the component.

The graph instance is not affected by this and will keep its references and listeners. To remove them, set the graph to a new empty default graph. Otherwise, re-using the graph in another component may cause unexpected behavior.

In addition, the entire visual tree is cleared and an immediate final visual tree update is performed. As a result, pending dispose callbacks for registered visuals are executed and associated resources can be released.

Helper method that ensures that the viewport limit as returned by the viewportLimiter is obeyed.
This method will zoomTo the limited bounds if necessary.

Parameters

mode?: ViewportLimitingMode
The mode defining how viewport limitations are applied. Defaults to PROGRAMMATIC_NAVIGATION.

See Also

API
viewportLimiter
Creates an appropriate IRenderContext that can be used to create visuals using IVisualCreator implementations.
This method is a convenience method to obtain a context for special visual creator implementations and normally needs not be used by application developers.

Return Value

IRenderContext
A new context instance that is bound to this instance.
Ensures that the provided bounds in world coordinates are visible by adjusting the viewport accordingly.

Parameters

bounds: Rect
The bounds to make visible.
viewportPadding?: Insets
Padding in view coordinates to keep free around the content.
mode?: ViewportLimitingMode
The mode the viewport limiter should use.

Return Value

Promise<void>
A Promise<void> that completes when the viewport has been adjusted.

See Also

Developer's Guide
Ensures that the provided points in world coordinates are all visible by adjusting the viewport accordingly.
This is particularly useful when using a projection because rectangles in the viewport may not be rectangles in world coordinates, sometimes requiring excessive padding.

Parameters

points: IEnumerable<Point>
The points to make visible.
viewportPadding?: Insets
Padding in view coordinates to keep free around the content.
mode?: ViewportLimitingMode
The mode the viewport limiter should use.

Return Value

Promise<void>
A Promise<void> that completes when the viewport has been adjusted.

See Also

Developer's Guide
Executes the given command with the given optional parameter on this CanvasComponent.

See the documentation of the Command for which parameters can be used with the given command.

It is strongly advised to query canExecuteCommand whether the command can be executed.

Some commands can only be executed if a GraphViewerInputMode or GraphEditorInputMode is installed.

final

Parameters

command: Command
The command to execute.
parameter?: any
An optional parameter to provide for the command.

See Also

API
Command, addCommandBinding
Fires the size changed event.
final

Parameters

oldSize: Size
The old size.
Adjusts the viewport to fully encompass the contentBounds.

This is usually used to make sure a large graph fits into the viewport. The limitFitContentZoom property controls the behavior for small graphs. If limitFitContentZoom is true, the maximum zoom level is 1; setting the property to false will zoom in far enough so that even small graphs fit the viewport (limited to maximumZoom, though).

The viewportLimiter is taken into account.

If a projection is set, the bounding rectangle of the contentBounds is used and and viewportLimiter is ignored.

Parameters

animated?: boolean
Whether to change the viewport in an animated fashion.

Return Value

Promise<void>
A Promise<void> that completes when the viewport has been adjusted.

See Also

Developer's Guide
API
updateContentBounds, zoom, zoomTo

Parameters

margins?: Insets
The visible whitespace around the actual contentBounds.
animated?: boolean
Whether to change the viewport in an animated fashion.

Return Value

Promise<void>
A Promise<void> that completes when the viewport has been adjusted.

See Also

Developer's Guide
Focuses the htmlElement element that is backing this instance.
final

Parameters

options?: FocusOptions
The optional focus options.
Gets the LookupDecorator<IInputModeContext, TInterface> that can be used to decorate the lookup call in the inputModeContext.
final

Parameters

interfaceType: Constructor<TInterface>

Return Value

LookupDecorator<IInputModeContext, TInterface>
The LookupDecorator<IInputModeContext, TInterface> instance that can be used for decorating the lookup operation within the context.
Determines the animation duration for a viewport animation.
Returning ZERO will disable the animation completely. For viewport changes that have been disabled via animatedViewportChanges the duration is never queried.
When overriding this method, it is recommended to always call the base implementation first, and, if ZERO is returned, to return that value immediately as well. The reason behind that is that high-precision scroll devices, like Apple's Trackpad, Microsoft's Precision Touchpad, or mice with free-turning scroll wheels, are automatically detected and the animation is turned off to improve interaction smoothness.
protected

Parameters

newCenter: Point
The new center of the viewport.
newZoom: number
The new zoom factor.
viewportChanges: ViewportChanges
The kind of viewport change that triggered this method. Even though ViewportChanges supports multiple values as bitwise flags, only one of them is ever passed here.

Return Value

TimeSpan
A TimeSpan indicating the desired animation duration.

Examples

The following example shows a few different ways how this method can be used to customize the animation duration (or whether to animate at all):
Customizing the viewport animation duration for different scenarios
protected getViewportAnimationDuration(
  newCenter: Point,
  newZoom: number,
  viewportChanges: ViewportChanges,
): TimeSpan {
  if (
    viewportChanges == ViewportChanges.MOUSE_WHEEL_SCROLL &&
    this.center.distanceTo(newCenter) > 200
  ) {
    // Use a duration between 100 and 500 ms depending on the distance scrolled
    return TimeSpan.fromMilliseconds(
      Math.max(Math.min(this.center.distanceTo(newCenter), 500), 100),
    )
  }
  if (
    (viewportChanges == ViewportChanges.ZOOM_COMMAND ||
      viewportChanges == ViewportChanges.MOUSE_WHEEL_ZOOM) &&
    newZoom > this.zoom
  ) {
    // Use a shorter duration when zooming in
    return TimeSpan.fromMilliseconds(100)
  }
  if (viewportChanges == ViewportChanges.FIT_CONTENT_COMMAND) {
    // Never animate FIT_CONTENT or FIT_GRAPH_BOUNDS
    return TimeSpan.ZERO
  }
  return super.getViewportAnimationDuration(
    newCenter,
    newZoom,
    viewportChanges,
  )
}

See Also

Developer's Guide
API
animatedViewportChanges
Ensures that the contentBounds encompasses the given rectangle.
Note that this will not change the viewport, it will only change the scrollbars if necessary.
final

Parameters

rectangle: Rect
The rectangle that should be included in the content bounds
Used by the default implementation of inputModeContext to resolve lookup calls.
protected

Parameters

context: IInputModeContext
The context.
type: Constructor
The Type to query

Return Value

any
The result of the query.

See Also

API
IInputModeContext
Converts intermediate coordinates to view coordinates expressed in the control's coordinate system.
Essentially, this applies the set projection. If no projection is set, this method has no effect.
final

Parameters

intermediatePoint: Point
the coordinates in the view coordinate system

Return Value

Point
The coordinates in pixels relative to the control's upper left corner in the view coordinate system

See Also

Developer's Guide
Converts intermediate coordinates to world coordinates.
If no projection is set, this method produces the same result as viewToWorldCoordinates
final

Parameters

intermediatePoint: Point
Coordinates expressed in the intermediate coordinate system

Return Value

Point
The coordinates expressed in the world coordinate system.

See Also

Developer's Guide
Invalidates this instance and marks it as in need for an update.

Calling this method is fast and will only mark the component as dirty for a future, asynchronously executed call to updateVisual.

Alternatively, updateVisualAsync can be used which returns a promise that is resolved once the component has been updated.

final
Returns an instance that implements the given type or null.
Typically, this method will be called to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile-time constraints. An instance implementing this method is not required to return non-null implementations for the types, nor does it have to return the same instance any time. Also, it depends on the type and context whether the instance returned stays up to date or needs to be re-obtained for further use.

Parameters

type: Constructor<T>
the type for which an instance shall be returned

Return Value

T
an instance that is assignable to the type or null
Calls evt.preventDefault() for each contextMenu event that occurs on this instance.
By overriding this method, the browser's default behavior for the contextMenu event can be enabled.
protected

Parameters

evt: Event
The event.
Calls evt.preventDefault() if captureAllPointerInput is enabled.
This method is queried for each mouse, touch or pointer event that occurs on this instance. By overriding this method, the browser's default behavior can effectively be controlled for every single event.
protected

Parameters

evt: Event
The event.
This method will be called when the mouse wheel was turned and if the mouseWheelBehavior property is set to SCROLL.
This method will scroll the view in vertical direction. If the Shift key modifier has been pressed this method will scroll in horizontal direction.
protected

Parameters

evt: PointerEventArgs
The event describing the action

See Also

API
mouseWheelBehavior, mouseWheelScrollFactor
This method will be called when the mouse wheel was turned and if the mouseWheelBehavior property is set to ZOOM.
This method will adjust the current zoom level. If the Control key modifier has not been pressed, this method will keep the world coordinates at the current mouse position, i.e. the zoom will not necessarily be into the center of the canvas.
protected

Parameters

evt: PointerEventArgs
the event describing the action

See Also

API
mouseWheelBehavior
Converts html page coordinates to view coordinates.
final

Parameters

pageLocation: Point
The html page coordinates to convert.

Return Value

Point
The view coordinates.
Converts html page coordinates to world coordinates.
final

Parameters

pageLocation: Point
The html page coordinates to convert.

Return Value

Point
The world coordinates.
Stops the mouse capture and returns to normal event capturing.
When mouseCapture is set to true and a mouse down event is received, the control starts capturing all mouse events by registering handlers on the document element. Mouse capturing is normally stopped when the mouse button is released. Mouse capture can be manually stopped by calling this function.
final
Updates the contentBounds to encompass the bounds of all elements in the current scene graph plus the given margins.
This method will traverse all visible elements in the subgraph below the given group of scene graph and query their bounds. The resulting bounds will be set to the content bounds plus the provided margins.

Parameters

margins?: Insets
The additional margins to add to the calculated bounds.
group?: IRenderTreeGroup
The scene graph group to traverse. If none is specified, the contentGroup is used.

See Also

Developer's Guide
API
IBoundsProvider, contentBounds
Updates the visual tree that displays the contents of this control.

Calling this method will synchronously update the visual tree and the SVG DOM and Canvas rendering.

This method will create or update the visuals that make up the visual tree.

Note that most of the time this method does not need to be called by client code. Instead calling invalidate will ultimately trigger this method. However invalidation calls will be coalesced and the actual execution of the update will be delayed until the next event dispatch.

See Also

Developer's Guide
Invalidates this instance and marks it as in need for an update.
This method is similar in functionality to invalidate, but it will yield a Promise that resolves once updateVisual was called asynchronously.
final

Return Value

Promise<void>
A Promise that will resolve once the component has been updated
Converts view coordinates to intermediate coordinates, effectively canceling any projection if set.
If no projection is set, this method has no effect
final

Parameters

viewPoint: Point
the coordinates in the view coordinate system

Return Value

Point
The coordinates in pixels relative to the control's upper left corner in the intermediate coordinate system

See Also

Developer's Guide
Converts view coordinates to the html page coordinates.
final

Parameters

viewLocation: Point
The view coordinates to convert.

Return Value

Point
The coordinates in the html document's coordinate system.
Converts coordinates expressed in the component's coordinate system to world coordinates.
final

Parameters

viewPoint: Point
the coordinates in pixels relative to the component's upper left corner

Return Value

Point
The coordinates expressed in the world coordinate system

See Also

Developer's Guide
Converts world coordinates to the component's coordinate system before the projection is applied.
If no projection is set, this method produces the same result as worldToViewCoordinates
final

Parameters

worldPoint: Point
the coordinates in the world coordinate system

Return Value

Point
Coordinates expressed in pixels relative to the control's upper left corner in the intermediate coordinate system

See Also

Developer's Guide
Converts world coordinates to view coordinates expressed in the control's coordinate system.
final

Parameters

worldPoint: Point
Coordinates in the world coordinate system

Return Value

Point
The coordinates in pixels relative to the control's upper left corner

See Also

Developer's Guide
Sets the zoom level and viewport center so that the given rectangle in world coordinates fits the viewport.
This method does not take the viewportLimiter into account.

Parameters

bounds: Rect
The coordinates of the rectangle to zoom to.

Examples

Change the viewport so that a given rectangle fits exactly
graphComponent.zoomTo(new Rect(50, 30, 120, 75))

See Also

Developer's Guide
API
zoomTo, zoomToAnimated
Sets the zoom level and viewport center to the given values.
This method effectively sets both the center and zoom properties and does not take the viewportLimiter into account.

Parameters

zoom: number
The new zoom level.
center?: Point
The optional new center of the viewport in world coordinates. If not specified, this implementation zooms to the current viewport center.

Examples

Change the viewport to a new center point with a new zoom level
graphComponent.zoomTo(2, new Point(42, 42))

See Also

Developer's Guide
API
zoomTo, zoomToAnimated
Transitions the viewport in an animated fashion to a new zoom level and center so that the given rectangle in world coordinates fits the viewport.
This method does not take the viewportLimiter into account.

Parameters

bounds: Rect
The coordinates of the rectangle to zoom to.

Return Value

Promise<void>
A Promise that resolves when the viewport has been adjusted.

Examples

Animate the viewport so that a given rectangle fits exactly
await graphComponent.zoomToAnimated(new Rect(50, 30, 120, 75))
// Subsequent code runs after the animation completes

See Also

Developer's Guide
API
zoomTo, zoomToAnimated
Transitions to a new zoom level and viewport center in an animated fashion.
This method does not take the viewportLimiter into account.

Parameters

zoom: number
The new zoom level.
center?: Point
The optional new center of the viewport in world coordinates. If not specified, this implementation zooms to the current viewport center.

Return Value

Promise<void>
A Promise that resolves once the animation is finished.

Examples

Animate the viewport to a new center point with a new zoom level
await graphComponent.zoomToAnimated(2, new Point(42, 42))
// Subsequent code runs after the animation completes

See Also

Developer's Guide
API
zoomToAnimated, zoomTo

Events

Occurs when the executability state of a command might have changed.
This event is raised when conditions which might determine the executability of a Command might have changed. This can apply to all Commands, so implementors have to re-query canExecuteCommand for each command where a change might be relevant.

Properties of

EventArgs

See Also

API
Command, addCommandBinding
Occurs when the contentBounds have been changed.
Occurs when the currentItem property has changed its value.
propertyName: string
The name of the changed property.
Occurs when keys are being pressed, i.e., on keydown.
This event delivers KeyEventArgs.

Properties of

KeyEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: KeyEventType
Gets the type of the event.
key: string
Gets the key.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the modifiers.
originalEvent: KeyboardEvent
Gets the original DOM event associated with this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
Occurs when keys are being released, i.e., on keyup.
This event delivers KeyEventArgs.

Properties of

KeyEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: KeyEventType
Gets the type of the event.
key: string
Gets the key.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the modifiers.
originalEvent: KeyboardEvent
Gets the original DOM event associated with this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
Occurs when the mouse capture has been lost.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse capture has been lost.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the user clicks the pointer.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

This happens if press and release happens at the same position.

This refers to all supported pointer clicks, i.e. mouse clicks, touch taps, and stylus clicks.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when a mouse button has been pressed, i.e., on mousedown.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse is being moved while at least one of the mouse buttons is pressed.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse has entered the canvas.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

If the mouse enters this canvas control with a mouse button pressed, this event is fired instantly but the current button state reported by the PointerEventArgs does not include this button unless the browser supports the property MouseEvent.buttons. See the Known Issues for more details.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse has exited the canvas.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

If the mouse leaves this canvas control with the mouse button pressed, this event is deferred until the mouse button is released. Thus, this event will not interfere with the typical mouse button event cycle.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the user performed a long press gesture with a pointer device.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

This happens if the pointer is held in the same position for the duration specified in longPressTime after a pointer-down.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs during a DRAG or MOVE, when the pointer only moves a lit bit during the amount of time specified in longRestTime.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse has been moved in world coordinates.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

Move elements are delivered if no mouse button is pressed. This event will be fired, too, if the mouse does not move but the world coordinates to which the current mouse position maps change. E.g. this will happen if the zoom level or the view point is changed.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the mouse button has been released, i.e., on mouseup.
This event delivers PointerEventArgs in world coordinates using double precision floating points.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs before the visual tree is painted to prepare the IRenderContext.
context: IRenderContext
writable
Gets or sets the context.
Occurs if the selection instance has been changed, not when the selected items change.
This event fires rarely. The selection property is only the selection model, thus this event is raised when the selection model instance itself changes. To listen to changes in the GraphComponent's selection, please refer to the appropriate events on IGraphSelection.
item: T
Gets the item that is the subject of the event.

See Also

API
item-added, item-removed
Occurs when the size of this component is changed.

Properties of

SizeChangedEventArgs
oldSize: Size
Gets or sets the old size of the control.
source: HTMLElement
Gets or sets the element whose size was changed.
Occurs before the visual tree is updated.
Occurs when the viewport property has been changed.
propertyName: string
The name of the changed property.

See Also

Developer's Guide
Occurs when the mouse wheel has turned.

This event delivers PointerEventArgs in world coordinates using double precision floating points.

The default mouseWheelBehavior can be omitted by calling preventDefault on the event args.

Properties of

PointerEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier is pressed.
buttons: PointerButtons
Gets the state of the device buttons at the time of the event creation.
changedButtons: PointerButtons
Gets the mouse buttons that have changed for this event.
changedModifiers: ModifierKeys
Gets the modifier keys that have changed for this event.
clickCount: number
Gets the number of clicks the current event represents if it is of type CLICK.
ctrlKey: boolean
Gets a value indicating whether the control modifier is pressed.
defaultPrevented: boolean
Gets a value indicating whether the default behaviors for this event have been prevented by a previous call to preventDefault.
eventType: PointerEventType
Gets the type of this event.
isPrimary: boolean
Indicates if the pointer represents the primary pointer of this type.
location: Point
Gets the coordinates in the world coordinate space associated with this event.
metaKey: boolean
Gets a value indicating whether the meta modifier is pressed.
modifiers: ModifierKeys
Gets the state of the modifier keys at the time of the event creation.
originalEvent: any
Gets the original DOM event associated with this event.
pointerId: number
The identifier assigned to the pointer causing the pointer event.
pointerSize: Size
The width and the height of the pointer's contact area.
pointerType: PointerType
Gets the device type that caused the pointer event.
pressure: number
The normalized pressure of the pointer input in the range of 0 to 1.
shiftKey: boolean
Gets a value indicating whether the shift modifier is pressed.
wheelDeltaX: number
Gets the signed number of mouse wheel turn units in horizontal direction.
wheelDeltaY: number
Gets the signed number of vertical mouse wheel turn units.
Occurs when the value of the zoom property has been changed.