The CanvasComponent can be used to efficiently display all kinds of data.
Remarks
The control supports high performance zooming and panning of visual content and provides a high level view of the visual tree. The control uses double precision world-coordinates to render items that are composed using a visual tree. In its most simple form the scene graph is a tree-like structure of elements that will be rendered in depth-first-search order.
The scene graph tree is made up of IRenderTreeElement elements, all managed by the renderTree. Multiple elements are grouped in IRenderTreeGroup elements. An IRenderTreeElement consists of a render tag and an IObjectRenderer<Object> that is used by the rendering engine to query interfaces that perform the actual creation of the Visuals, hit testing, and bounds calculation.
A projection that is applied to the whole scene graph can be set to simulate different parallel projections of the CanvasComponent's content (e.g. isometric).
This component handles the following commands by default:
The handlers for INCREASE_ZOOM and DECREASE_ZOOM use the specified command parameter as the factor by which the zoom value is multiplied or divided, respectively. The parameter is not required. If it is not present, a default value is used. The handler for the ZOOM command needs a parameter. The parameter can either be a number which is interpreted as the new zoom level, or it can be a suitable object. Supported objects are Rect, Point and ILookup. If a rectangle is specified as the parameter for the ZOOM command, the handler adjusts the viewport such that the rectangle tightly fits into it. If a point is specified, the handler sets the center to that point. If the parameter implements ILookup, then the handler tries to get a IBoundsProvider from the lookup and uses the bounds obtained from the bounds provider as the rectangle to zoom to.
Also, PRINT and PRINT_PREVIEW are supported out of the box.
Related Reading in the Developer's Guide
Type Details
- yFiles module
- view
See Also
Constructors
Creates a new instance of CanvasComponent for the provided htmlElement
.
Remarks
The canvas will be empty with no associated inputMode.
All child nodes of the htmlElement
are added to the overlayPanel.
Parameters
A map of options to pass to the method.
- htmlElement - HTMLElement
- The existing element 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 CanvasComponent using the div
element that is specified by the selector
.
Remarks
The canvas will be empty with no associated inputMode.
All child nodes of the div
element are passed to the overlayPanel.
Parameters
A map of options to pass to the method.
- selector - string
- The CSS selector or id for an existing
div
element. All child nodes of this element are added to the overlayPanel
Throws
- Exception({ name: 'ArgumentError' })
- if the <div> element specified by the
selector
is already used by another component.
Creates a new instance of CanvasComponent with default properties.
Remarks
Properties
Gets or sets a combination of viewport changes that should be performed in an animated fashion.
Property Value
Examples
graphComponent.animatedViewportChanges =
ViewportChanges.MOUSE_WHEEL_ZOOM | ViewportChanges.ZOOM_COMMAND
See Also
Gets the aria-live region of the CanvasComponent.
Remarks
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.
Gets or sets the distance from the edge of the viewport, in which auto-scrolling should happen.
Remarks
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)
Property Value
See Also
Gets an implementation of ICanvasContext that describes the state of this CanvasComponent.
See Also
Gets or sets the world coordinate at the center of the control.
Remarks
Examples
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
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.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Examples
graphComponent.centerZoomEventRecognizer = EventRecognizers.SHIFT_IS_DOWN
graphComponent.centerZoomEventRecognizer = EventRecognizers.NEVER
See Also
Gets and sets the rectangle in world coordinates that holds the contents.
Remarks
See Also
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.
Remarks
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)
See Also
Gets or sets the value of the double-click time.
Remarks
Gets the dropTarget associated with this instance.
Property Value
Gets a value indicating whether this CanvasComponent is currently focused.
Property Value
true
if focused; otherwise, false
.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.
Remarks
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.
See Also
Gets or sets the visibility policy for the horizontal scrollbar.
Remarks
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.
When setting either scrollbar policy (or both) to AUTO both scrollbars overlay the content and vanish automatically when not currently interacted with.
See Also
Gets or sets an event recognizer that determines whether the mouse wheel should scroll in horizontal instead of vertical direction.
Remarks
This recognizer is only used if mouseWheelBehavior has the SCROLL flag.
The default is SHIFT_IS_DOWN.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Examples
graphComponent.horizontalScrollEventRecognizer =
EventRecognizers.CTRL_DOWN
Gets or sets the image-rendering type for this visual and its children.
Remarks
Gets the size of the usable area in which the graph will be displayed.
Remarks
Gets or sets the single IInputMode instance that shall be installed for this canvas.
Examples
graphComponent.inputMode = new GraphEditorInputMode()
// set a new instance - by default, a GraphViewerInputMode is already set
graphComponent.inputMode = new GraphViewerInputMode()
See Also
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).
Remarks
Gets the last pointer event triggered by this instance.
See Also
Gets or sets a value indicating whether the maximum zoom level for fitContent and FIT_CONTENT is limited to 1.
Remarks
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
.
Gets or sets the duration a pointing device must be held down without moving before the pointer-long-press event is raised.
Remarks
Small pointer moves are ignored, so jittery pointer types like PEN or TOUCH will not block the event.
The default value is 250 milliseconds.
See Also
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.Gets or sets the duration a pointing device must not move before the pointer-long-rest event is raised.
Gets or sets the maximum zoom factor for this CanvasComponent.
Remarks
100000.0
and the enforced maximum value is 1000000.0
.Examples
graphComponent.maximumZoom = 4
See Also
Gets or sets the minimum zoom factor for this CanvasComponent.
Remarks
0.0001
, the enforced minimum 0.0000001
.Examples
graphComponent.minimumZoom = 1
See Also
Gets or sets a value that specifies whether this control receives mouse input after the mouse is dragged out of its bounding area.
Remarks
Gets or sets the action to perform when turning the mouse wheel.
Remarks
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. This is the default.
- 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 scrolling vertically. Pressing Shift while turning the mouse wheel will scroll horizontally. Zooming will happen when the mouseWheelZoomEventRecognizer is satisfied (by default this is pressing Control while turning the mouse wheel).
- 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.
Examples
// 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
Gets or sets a factor that controls how fast the viewport scrolls when the mouse wheel is turned.
Remarks
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.
See Also
Gets or sets an event recognizer that determines whether turning the mouse wheel should perform zooming instead of scrolling.
Remarks
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.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Examples
graphComponent.mouseWheelZoomEventRecognizer =
EventRecognizers.ALT_IS_DOWN
See Also
Gets or sets the factor by which the zoom level changes when the mouse wheel is turned.
Gets or sets an event recognizer that temporarily enables mouse wheel events.
Remarks
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.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
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.
Remarks
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.
Gets or sets a value indicating whether input coordinates (mouse and touch) should be quantized depending on the zoom level to give nicer values.
Remarks
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
.
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.
Remarks
Property Value
true
if the main UI direction is right to left; otherwise, false
.Gets or sets the shape-rendering type for this visual and its children.
Remarks
Returns the size of the HTML element.
Gets the control's svgDefsManager
Gets or sets whether to add a 'glass pane' overlay to the CanvasComponent that acts as the source for all mouse and touch events.
Remarks
Gets or sets the visibility policy for the vertical scrollbar.
Remarks
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.
When setting either scrollbar policy (or both) to AUTO both scrollbars overlay the content and vanish automatically when not currently interacted with.
See Also
Gets or sets the current viewpoint.
Remarks
Examples
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
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.
Remarks
By default, there are no limits set on the explorable region.
When a projection is set, the viewportLimiter is ignored.
See Also
Gets or sets the policy for caching Visuals which are temporarily removed from the visual tree.
Remarks
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.
Gets or sets the zoom factor for this CanvasComponent.
Remarks
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
Examples
console.log(
`Resetting the zoom level from ${graphComponent.zoom} to 100 %.`,
)
graphComponent.zoom = 1
See Also
Methods
addGenericInputModeContextLookup
(genericLink: function(IInputModeContext, Constructor, IContextLookup):any) : IContextLookupChainLinkAdds a generic callback as a chain link to the lookup.
Remarks
Parameters
A map of options to pass to the method.
- genericLink - function(IInputModeContext, Constructor, IContextLookup):any
- The generic callback to add to the lookup chain.
Signature Details
function(arg1: IInputModeContext, arg2: Constructor, arg3: IContextLookup) : any
Encapsulates a method that has three parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IInputModeContext
- The first parameter of the method that this delegate encapsulates.
- arg2 - Constructor
- The second parameter of the method that this delegate encapsulates.
- arg3 - IContextLookup
- The third parameter of the method that this delegate encapsulates.
Returns
- any
- The return value of the method that this delegate encapsulates.
Returns
- ↪IContextLookupChainLink
- An IContextLookupChainLink that has been added to the lookup.
Returns whether the given command
can be executed with the given optional parameter
.
Remarks
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.
Parameters
A map of options to pass to the method.
- command - Command
- The command to execute.
- parameter - any
- An optional parameter to provide for the command.
Returns
- ↪boolean
- Returns
true
if the command can be executed, otherwisefalse
.
See Also
Cleans up by removing any connection from the htmlElement element to the CanvasComponent instance and any associated element that was created during the lifetime of the component.
Remarks
This method should be called when the component is not needed anymore and should be garbage collected. After calling this method the component must not be used anymore.
During this call, 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.
Remarks
Parameters
A map of options to pass to the method.
- mode - ViewportLimitingMode
- The mode defining how viewport limitations are applied. Defaults to PROGRAMMATIC_NAVIGATION.
See Also
Creates an appropriate IRenderContext that can be used to create visuals using IVisualCreator implementations.
Remarks
Returns
- ↪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
A map of options to pass to the method.
- 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.
Returns
See Also
ensureVisible
(points: IEnumerable<Point>, viewportPadding?: Insets, mode?: ViewportLimitingMode) : Promise<void>Ensures that the provided points in world coordinates are all visible by adjusting the viewport accordingly.
Remarks
Parameters
A map of options to pass to the method.
- 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.
Returns
See Also
Executes the given command
with the given optional parameter
on this CanvasComponent.
Remarks
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.
Parameters
A map of options to pass to the method.
- command - Command
- The command to execute.
- parameter - any
- An optional parameter to provide for the command.
See Also
Exports the graphical content for this CanvasComponent.
Remarks
This method will create the visual content using the world coordinate system.
Note that for creating standalone SVG exports, the SvgExport should be used instead.
Note that no viewport transform will be applied. Additionally, a projection will be applied only to canvas visuals. SVG visuals will be exported unprojected.
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The context to use.
Returns
- ↪Element
- An SVG element that represents the contents of this control.
See Also
Adjusts the viewport to fully encompass the contentBounds.
Remarks
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
A map of options to pass to the method.
- animated - boolean
- Whether to change the viewport in an animated fashion.
Returns
See Also
Focuses the htmlElement element that is backing this instance.
Parameters
A map of options to pass to the method.
- options - FocusOptions
- The optional focus options.
getInputModeContextDecoratorFor
<TInterface>(interfaceType: Constructor<TInterface>) : LookupDecorator<IInputModeContext,TInterface>Gets the LookupDecorator<IInputModeContext,TInterface> that can be used to decorate the lookup call in the inputModeContext.
Type Parameters
- TInterface
Returns
- ↪LookupDecorator<IInputModeContext,TInterface>
- The LookupDecorator<IInputModeContext,TInterface> instance that can be used for decorating the lookup operation within the context.
getViewportAnimationDuration
(newCenter: Point, newZoom: number, viewportChanges: ViewportChanges) : TimeSpanDetermines the animation duration for a viewport animation.
Remarks
Parameters
A map of options to pass to the method.
- 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.
Returns
Examples
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
Ensures that the contentBounds encompasses the given rectangle.
Remarks
Parameters
A map of options to pass to the method.
- rectangle - Rect
- The rectangle that should be included in the content bounds
Used by the default implementation of inputModeContext to resolve lookup calls.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context.
- type - Constructor
- The Type to query
Returns
- ↪any?
- The result of the query.
See Also
Converts intermediate coordinates to view coordinates expressed in the control's coordinate system.
Remarks
Parameters
A map of options to pass to the method.
- intermediatePoint - Point
- the coordinates in the view coordinate system
Returns
- ↪Point
- The coordinates in pixels relative to the control's upper left corner in the view coordinate system
See Also
Converts intermediate coordinates to world coordinates.
Remarks
Parameters
A map of options to pass to the method.
- intermediatePoint - Point
- Coordinates expressed in the intermediate coordinate system
Returns
- ↪Point
- The coordinates expressed in the world coordinate system.
See Also
Invalidates this instance and marks it as in need for an update.
Remarks
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.
Returns an instance that implements the given type or null
.
Remarks
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.Type Parameters
- T
Parameters
A map of options to pass to the method.
- type - Constructor<T>
- the type for which an instance shall be returned
Returns
- ↪T?
- an instance that is assignable to the type or
null
See Also
Implements
Calls evt.preventDefault()
for each contextMenu
event that occurs on this instance.
Remarks
contextMenu
event can be enabled.Parameters
A map of options to pass to the method.
- evt - Event
- The event.
Calls evt.preventDefault()
if captureAllPointerInput is enabled.
Remarks
Parameters
A map of options to pass to the method.
- evt - Event
- The event.
This method will be called when the mouse wheel was turned and if the mouseWheelBehavior property is set to SCROLL.
Remarks
Parameters
A map of options to pass to the method.
- evt - PointerEventArgs
- The event describing the action
See Also
This method will be called when the mouse wheel was turned and if the mouseWheelBehavior property is set to ZOOM.
Remarks
Parameters
A map of options to pass to the method.
- evt - PointerEventArgs
- the event describing the action
See Also
Converts html page coordinates to view coordinates.
Converts html page coordinates to world coordinates.
Stops the mouse capture and returns to normal event capturing.
Remarks
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.Updates the contentBounds to encompass the bounds of all elements in the current scene graph plus the given margins.
Remarks
group
of scene graph and query their bounds. The resulting bounds will be set to the content bounds plus the provided margins
.Parameters
A map of options to pass to the method.
- 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
Updates the visual tree that displays the contents of this control.
Remarks
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
Invalidates this instance and marks it as in need for an update.
Remarks
Returns
Converts view coordinates to intermediate coordinates, effectively canceling any projection if set.
Remarks
Parameters
A map of options to pass to the method.
- viewPoint - Point
- the coordinates in the view coordinate system
Returns
- ↪Point
- The coordinates in pixels relative to the control's upper left corner in the intermediate coordinate system
See Also
Converts view coordinates to the html page coordinates.
Converts coordinates expressed in the component's coordinate system to world coordinates.
Converts world coordinates to the component's coordinate system before the projection is applied.
Remarks
Parameters
A map of options to pass to the method.
- worldPoint - Point
- the coordinates in the world coordinate system
Returns
- ↪Point
- Coordinates expressed in pixels relative to the control's upper left corner in the intermediate coordinate system
See Also
Converts world coordinates to view coordinates expressed in the control's coordinate system.
Sets the zoom level and viewport center to the given values.
Remarks
Parameters
A map of options to pass to the method.
- 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
graphComponent.zoomTo(2, new Point(42, 42))
See Also
Sets the zoom level and viewport center so that the given rectangle in world coordinates fits the viewport.
Remarks
Parameters
A map of options to pass to the method.
- bounds - Rect
- The coordinates of the rectangle to zoom to.
Examples
graphComponent.zoomTo(new Rect(50, 30, 120, 75))
See Also
Transitions to a new zoom level and viewport center in an animated fashion.
Remarks
Parameters
A map of options to pass to the method.
- 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.
Returns
- ↪Promise<void>
- A Promise that resolves once the animation is finished.
Examples
await graphComponent.zoomToAnimated(2, new Point(42, 42))
// Subsequent code runs after the animation completes
See Also
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.
Remarks
Parameters
A map of options to pass to the method.
- bounds - Rect
- The coordinates of the rectangle to zoom to.
Returns
- ↪Promise<void>
- A Promise that resolves when the viewport has been adjusted.
Examples
await graphComponent.zoomToAnimated(new Rect(50, 30, 120, 75))
// Subsequent code runs after the animation completes
See Also
Events
Occurs when the executability state of a command might have changed.
Remarks
See Also
Occurs when the contentBounds have been changed.
Occurs when keys are being pressed, i.e., on keydown
.
Remarks
Occurs when keys are being released, i.e., on keyup
.
Remarks
Occurs when the mouse capture has been lost.
Remarks
Occurs when the mouse capture has been lost.
Remarks
Occurs when the user clicks the pointer.
Remarks
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.
Occurs when a mouse button has been pressed, i.e., on mousedown
.
Remarks
Occurs when the mouse is being moved while at least one of the mouse buttons is pressed.
Remarks
Occurs when the mouse has entered the canvas.
Remarks
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.
Occurs when the mouse has exited the canvas.
Remarks
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.
Occurs when the user performed a long press gesture with a pointer device.
Remarks
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.
Occurs during a DRAG or MOVE, when the pointer only moves a lit bit during the amount of time specified in longRestTime.
Remarks
Occurs when the mouse has been moved in world coordinates.
Remarks
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.
Occurs when the mouse button has been released, i.e., on mouseup
.
Remarks
Occurs before the visual tree is painted to prepare the IRenderContext.
Occurs when the size of this component is changed.
Occurs after the visual tree has been updated.
Occurs before the visual tree is updated.
Occurs when the viewport property has been changed.
See Also
Occurs when the mouse wheel has turned.
Remarks
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.
Occurs when the value of the zoom property has been changed.
See Also
Static Methods
Gets the CanvasComponent instance that is associated with the given element, or null.
Parameters
A map of options to pass to the method.
- element - Element
- The element to get the CanvasComponent for.
Returns
- ↪CanvasComponent?
- The CanvasComponent instance that is associated with the given element, or
null
.