$getCapabilityConfig
Gets the config for some capability. May be an empty object. A capability provider may be registered at the point that a capability is registered - the function is provided by the code that registers the capability.
Signature
$getCapabilityConfig(c:UICapabilities)
Parameters
Return value
Record<string,any>$hasCapability
Test whether the specific capability is available on this instance of the UI.
Signature
$hasCapability(c:UICapabilities)
Parameters
addBackground
Adds a background. Theoretically you can add multiple backgrounds but the end result of that is indeterminate.
Signature
addBackground(background:Background)
Parameters
addClass
Adds a class to the DOM element represented by el, which can be a Selection, or an instance of many different types - see the SupportsClassManipulation interface for a complete list.
Signature
Parameters
addDragClassnameFilter
Adds a CSS class name filter to the drag handler - without the ..
Signature
addDragClassnameFilter(clazz:string | Array<string>)
Parameters
| clazz | string | Array<string> | Either a single class name, or a comma separated list of classnames, or an array of classnames. |
addDragFilter
Adds a filter to the drag handler.
Signature
addDragFilter(filter:(e:MouseEvent) => boolean, exclude:boolean)
Parameters
| filter | (e:MouseEvent) => boolean | |
| exclude | boolean | |
addDragSelectorFilter
Adds a CSS3 selector filter to the drag handler. A drag cannot start on an element that matches this selector. For more fine-grained control over dragging, see #addVertexDragFilter.
Signature
addDragSelectorFilter(selector:string)
Parameters
| selector | string | A valid CSS3 selector. |
addElementEventFilter
Adds a CSS3 selector filter which will exclude the given element (and descendants) from reporting element events. Used internally by popups, but exposed in the API as it may be useful.
Signature
addElementEventFilter(selector:string)
Parameters
| selector | string | A valid CSS3 selector. |
addPlugin<O,P>
Add a plugin to the UI. You can provide a type parameter to this method to avoid having to cast the return
value, if you need to retain a reference to the plugin.
Signature
Type Parameters
Parameters
addToDragGroup
Adds the given element(s) to the given drag group.
Signature
Parameters
| spec | DragGroupSpec | Either the ID of some drag group, in which case the elements are all added as 'active', or an object containing the ID of the drag group and the element's participation in the group. active participation, which is the default, indicates whether dragging the given element(s) should cause all the elements in the drag group to be dragged. If active is false it means the given element(s) is "passive" and should only move when an active member of the drag group is dragged. The elements passed in to this method will be added to the drag group with an added membership flag, meaning any drag group an element has been added to via this method will take precedence over a drag group an element gets added to via a drag group assigner (see the DragGroupsPlugin for a discussion of automatically assigning elements to drag groups) |
| els | Array<string | Node | Group | BrowserElement> | Elements to add to the drag group. |
addVertexDragFilter
Adds a filter function to the drag handler. A drag cannot start if this function returns false. See also #addDragSelectorFilter
Signature
Parameters
addWheelSelectorFilter
Adds a CSS selector filter to the wheel event.
Signature
addWheelSelectorFilter(selector:string)
Parameters
adHocGroupLayout
Run an adhoc layout on the given group. The layout will be applied one time, and then the previous layout will be restored (but not run, of course, otherwise the results of this adhoc layout would be overwritten!).
Signature
Parameters
| group | string | Group | The group on which to run an adhoc layout. |
| layoutParams | {
options:LayoutParameters, type:string
} | Params for the adhoc layout. |
adHocLayout<LP>
Run an adhoc layout on the viewport, inside a transaction, so the entire operation can be undone at once.
Note that invoking this method also has the effect of clearing the geometry of every edge and resetting edge
paths to the default computed values: edge paths are linked to their vertex locations, and this method can
move any vertex from its current location.
Signature
adHocLayout(layoutParams:{
options:LP,
type:string
})
Type Parameters
Parameters
| layoutParams | {
options:LP, type:string
} | Spec for the layout to apply |
alignBackground
Positions the widget so that the edges of the background align with the viewport. This method is useful for snapping to a corner of the background.
Signature
alignBackground(axes:string, animationDuration:number)
Parameters
| axes | string | Spec for the axes to align to. This should be a space-separated string containing a value for the x (allowed values left and right) and, optionally, y (allowed values top and bottom) axes. The default value is "left top". |
| animationDuration | number | Defaults to 150ms |
alignContent
Pan the canvas to align the content in one or both axes.
Signature
Parameters
alignContentBottom
Pan the canvas to align the content such that the bottom edge of the bottom element is at the bottom of the viewport.
Signature
Parameters
alignContentLeft
Pan the canvas to align the content such that the left edge of the leftmost element is at the left of the viewport.
Signature
Parameters
alignContentRight
Pan the canvas to align the content such that the right edge of the rightmost element is at the right of the viewport.
Signature
Parameters
alignContentTop
Pan the canvas to align the content such that the top edge of the topmost element is at the top of the viewport.
Signature
Parameters
attachMiniview
Attach a miniview to this Surface. This is a shortcut for adding one via addPlugin.
Signature
Parameters
autoSizeGroup
Run the group auto size routine on a given group (as well as any ancestor groups), and moves elements around as necessary
Signature
autoSizeGroup(
group:
Group,
force:
boolean)
Parameters
| group | Group | The group to auto size |
| force | boolean | If true, this flag will override an autoSize:false directive on the Group (and any ancestors). |
autoSizeGroups
Update the size of the given list of groups so that its content area encompasses all of the child elements of the group, unless force is not specified and a specific group has autoSize set to false.
Signature
autoSizeGroups(
groups:
Array<Group>,
force:
boolean)
Parameters
| groups | Array<Group> | Groups to size. If null, every group is auto sized. |
| force | boolean | If true, this flag will override an autoSize:false directive on the Group (and any ancestors) |
Return value
Record<string,GroupResizeResult<EL>>batch
Wraps the underlying model's batch function with the added step of first suspending events being fired from this renderer.
Signature
batch(fn:() => any)
Parameters
| fn | () => any | Function to run while rendering and events are both suspended. |
bind<T>
Bind a listener to the named event, optionally inserting the listener at the head of the queue for the given event.
Signature
bind(event:"pan" | "zoom" | "group:removed" | "edge:removed" | "node:removed" | "edge:geometry" | "edge:dragStart" | "edge:drag" | "edge:dragEnd" | "edge:dragAbort" | "group:move:start" | "group:move" | "group:move:end" | "internal:edge:redraw" | "node:move:start" | "node:move" | "node:move:end" | "node:move:abort" | "destroy" | "internal.connection" | "internal.element:repainted" | "group:collapse" | "group:expand" | "render:start" | "render:end" | "adhocLayout" | "afterLayoutRefresh" | "group:relayout" | "group:render" | "internal.vertex:updated" | "node:render" | "node:visibility" | "plugin:added" | "plugin:removed" | "relayout" | "vertex:click" | "vertex:dblclick" | "vertex:dbltap" | "vertex:mouseout" | "vertex:mouseover" | "vertex:mousemove" | "vertex:mouseup" | "vertex:mousedown" | "vertex:contextmenu" | "vertex:tap" | "edge:click" | "edge:dblclick" | "edge:mouseout" | "edge:mouseover" | "edge:mouseup" | "edge:mousedown" | "edge:contextmenu" | "canvasClick" | "canvasDblClick" | "edge:redraw" | "modeChanged", listener:(payload:T, evt:any) => any, insertAtStart:boolean)
Type Parameters
| T | | The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly. |
Parameters
| event | "pan" | "zoom" | "group:removed" | "edge:removed" | "node:removed" | "edge:geometry" | "edge:dragStart" | "edge:drag" | "edge:dragEnd" | "edge:dragAbort" | "group:move:start" | "group:move" | "group:move:end" | "internal:edge:redraw" | "node:move:start" | "node:move" | "node:move:end" | "node:move:abort" | "destroy" | "internal.connection" | "internal.element:repainted" | "group:collapse" | "group:expand" | "render:start" | "render:end" | "adhocLayout" | "afterLayoutRefresh" | "group:relayout" | "group:render" | "internal.vertex:updated" | "node:render" | "node:visibility" | "plugin:added" | "plugin:removed" | "relayout" | "vertex:click" | "vertex:dblclick" | "vertex:dbltap" | "vertex:mouseout" | "vertex:mouseover" | "vertex:mousemove" | "vertex:mouseup" | "vertex:mousedown" | "vertex:contextmenu" | "vertex:tap" | "edge:click" | "edge:dblclick" | "edge:mouseout" | "edge:mouseover" | "edge:mouseup" | "edge:mousedown" | "edge:contextmenu" | "canvasClick" | "canvasDblClick" | "edge:redraw" | "modeChanged" | Name of the event to bind |
| listener | (payload:T, evt:any) => any | Function to bind to the event |
| insertAtStart | boolean | Defaults to false. If true, this handler is inserted at the head of the list of listeners for the given event. |
Return value
EventGeneratorbindAll<T>
Bind a listener to all of the named events, optionally inserting each one at the head of the queue for the given event.
Signature
bindAll(events:Array<"pan" | "zoom" | "group:removed" | "edge:removed" | "node:removed" | "edge:geometry" | "edge:dragStart" | "edge:drag" | "edge:dragEnd" | "edge:dragAbort" | "group:move:start" | "group:move" | "group:move:end" | "internal:edge:redraw" | "node:move:start" | "node:move" | "node:move:end" | "node:move:abort" | "destroy" | "internal.connection" | "internal.element:repainted" | "group:collapse" | "group:expand" | "render:start" | "render:end" | "adhocLayout" | "afterLayoutRefresh" | "group:relayout" | "group:render" | "internal.vertex:updated" | "node:render" | "node:visibility" | "plugin:added" | "plugin:removed" | "relayout" | "vertex:click" | "vertex:dblclick" | "vertex:dbltap" | "vertex:mouseout" | "vertex:mouseover" | "vertex:mousemove" | "vertex:mouseup" | "vertex:mousedown" | "vertex:contextmenu" | "vertex:tap" | "edge:click" | "edge:dblclick" | "edge:mouseout" | "edge:mouseover" | "edge:mouseup" | "edge:mousedown" | "edge:contextmenu" | "canvasClick" | "canvasDblClick" | "edge:redraw" | "modeChanged">, listener:(payload:T, evt:any) => any, insertAtStart:boolean)
Type Parameters
| T | | The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly. |
Parameters
| events | Array<"pan" | "zoom" | "group:removed" | "edge:removed" | "node:removed" | "edge:geometry" | "edge:dragStart" | "edge:drag" | "edge:dragEnd" | "edge:dragAbort" | "group:move:start" | "group:move" | "group:move:end" | "internal:edge:redraw" | "node:move:start" | "node:move" | "node:move:end" | "node:move:abort" | "destroy" | "internal.connection" | "internal.element:repainted" | "group:collapse" | "group:expand" | "render:start" | "render:end" | "adhocLayout" | "afterLayoutRefresh" | "group:relayout" | "group:render" | "internal.vertex:updated" | "node:render" | "node:visibility" | "plugin:added" | "plugin:removed" | "relayout" | "vertex:click" | "vertex:dblclick" | "vertex:dbltap" | "vertex:mouseout" | "vertex:mouseover" | "vertex:mousemove" | "vertex:mouseup" | "vertex:mousedown" | "vertex:contextmenu" | "vertex:tap" | "edge:click" | "edge:dblclick" | "edge:mouseout" | "edge:mouseover" | "edge:mouseup" | "edge:mousedown" | "edge:contextmenu" | "canvasClick" | "canvasDblClick" | "edge:redraw" | "modeChanged"> | |
| listener | (payload:T, evt:any) => any | |
| insertAtStart | boolean | |
Return value
EventGeneratorbindModelEvent<T>
Binds to a mouse event occurring on a given model object. This is a wrapper around the on event binding method, which searches for an associated model object for the given event. For instance, you might have a node template that has a button inside of it that you want to respond to. When the button is clicked you want to know the node associated with the button. This method provides that. It is possible to find the associated model object yourself, via the getObjectInfo method of the Surface, called with the event's target, but this method does that for you.
You can, optionally, provide a type hint to this method in order to fix the type of the returned model object, but note that this is erased at runtime and the type of the returned object is not guaranteed by the surface.
This method binds a delegated event handler on the container element used by the surface. You do not need to provide an element to which to bind; you just need to provide an appropriate selector
Signature
Type Parameters
Parameters
| event | string | Name of the event to bind to. |
| selector | string | CSS3 selector that identifies children of a vertex DOM element on which the event handler should be bound. |
| callback | ModelEventCallback<T> | Function to call when the event is fired. |
bindUnchecked<T>
Bind an event listener. This method can be used with a type parameter by call sites; although it's not necessary it can be helpful to use this to ensure you've thought about what the payload to your event handler is going to be.
Signature
bindUnchecked(event:string, listener:(a:T, e:any) => any, insertAtStart:boolean)
Type Parameters
| T | | The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly. |
Parameters
| event | string | Name of the event(s) to bind to. |
| listener | (a:T, e:any) => any | Function to bind to the given event(s) |
| insertAtStart | boolean | Whether or not to insert this listener at the head of the listener queue. Defaults to false. |
Return value
EventGeneratorcenterBackground
Position the surface so the background is centered in the viewport, without changing the current zoom.
Signature
centerBackground(
params:
{
doNotAnimate:boolean,
onComplete:(p:PointXY) => any
})
Parameters
| params | {
doNotAnimate:boolean, onComplete:(p:PointXY) => any
} | |
centerContent
Centers the tracked content inside the viewport, but does not adjust the current zoom (so the content may still extend past the viewport bounds)
Signature
Parameters
centerContentHorizontally
Centers the tracked content horizontally inside the viewport, but does not adjust the current zoom (so the content may still extend past the viewport bounds)
Signature
Parameters
centerContentVertically
Centers the tracked content vertically inside the viewport, but does not adjust the current zoom (so the content may still extend past the viewport bounds)
Signature
Parameters
centerOn
Takes a single node/group, or an array of nodes/groups, and positions the surface canvas such that the given vertex/vertices is/are at the center in both axes. It does NOT change the zoom.
Signature
centerOn(
element:
string | Element | Vertex | Array<string | Element | Vertex>,
doNotAnimate:
boolean)
Parameters
| element | string | Element | Vertex | Array<string | Element | Vertex> | The element(s) to center. Can be a DOM element, vertex id, or a Node/Group, or an array of these. |
| doNotAnimate | boolean | |
centerOnAndZoom
Center on the current object/objects and zoom in on it/them.
Signature
centerOnAndZoom(
element:
string | Element | Vertex | Array<string | Element | Vertex>,
fillRatio:
number,
doNotAnimate:
boolean)
Parameters
| element | string | Element | Vertex | Array<string | Element | Vertex> | The element(s) to center. Can be a DOM element, vertex id, or a Node/Group, or an array of these. |
| fillRatio | number | How much of the viewport to fill with the object we zoom in on. This will be limited by the current zoom range. Defaults to 0.6. |
| doNotAnimate | boolean | by default, this operation will be animated. |
centerOnHorizontally
Takes a node/group as argument and positions the surface canvas such that the given node is at the center in the horizontal axis.
Signature
centerOnHorizontally(
element:
string | Element | Vertex)
Parameters
| element | string | Element | Vertex | The element to center. Can be a DOM element, vertex id, or a Node/Group |
centerOnVertically
Takes a node/group as argument and positions the surface canvas such that the given node is at the center in the vertical axis.
Signature
centerOnVertically(
element:
string | Element | Vertex)
Parameters
| element | string | Element | Vertex | The element to center. Can be a DOM element, vertex id, or a Node/Group |
clearDragGroup
Removes all members from the drag group with the given name.
Signature
clearDragGroup(name:string)
Parameters
clearPathEdits
Clear the edits for the given connection, returning its path to the automatically computed path.
Signature
Parameters
cloneVertex
Clones the given vertex. NOTE: this does not clone the children of a group. Only the group will be cloned, and it will be empty.
Signature
Parameters
collapseGroup
Collapse the given group, hiding all of its internal edges and proxying any edges to internal members to the collapsed element (unless the group definition for this group specifies proxied:false). Every edge with a source/target that is a descendant of this group is a candidate for proxying.
Signature
collapseGroup(
groupIdOrGroup:
string | Group)
Parameters
| groupIdOrGroup | string | Group | |
destroy
Cleans up the Surface. When using a library integration such as Angular/React/Vue/Svelte, this method will be called automatically when the associated component is unloaded. If you're using vanilla VisaullyJs, you might want to call this method if you're cleaning up your UI and you don't need this Surface any longer.
Signature
destroy()
expandGroup
Expand a collapsed group, unproxying any connections from the collapsed group to their original destination
Signature
expandGroup(
groupIdOrGroup:
string | Group)
Parameters
| groupIdOrGroup | string | Group | |
findEnclosedVertices
Finds all of the vertices that are enclosed by the rectangle described by origin and dimensions.
Signature
Parameters
findIntersectingVertices
Finds all of the vertices that intersect the rectangle described by origin and dimensions.
Signature
Parameters
fixElement
Appends an element to the viewport such that it is zoomed with everything else, but constrains placement in one or both axes so that the element remains fixed with respect to the viewport origin as the canvas pans and/or zooms. Note that this method will set position:absolute on the element you are fixing, because otherwise it would mess up the placement of the other content on the canvas. If you subsequently unfix an element, the UI does not remove the position:absolute style.
Signature
Parameters
| el | BrowserElement | The BrowserElement to append. |
| pos | PointXY | Location of the element's origin. |
| constraints | FixedElementConstraints | Flags to indicate optional constraint to each axis. |
| id | string | Optional ID to assign to the element, for future retrieval |
| onTop | boolean | |
flashSelection
Flash the nodes and groups in the given selection.
Signature
Parameters
| sel | VisuallyJsSelection | Selection to flash nodes and groups for |
| duration | number | Optional; defaults to 1000ms. Duration of the animation, in milliseconds. |
| animName | string | Optional; the name of the CSS animation to apply. Defaults to ANIM_SURFACE_ELEMENT_FLASH. |
flashVertex
Flash the given vertex or vertices.
Signature
flashVertex(
vertices:
string | Element | Node | Group | Array<string | Element | Node | Group>,
duration:
number,
animName:
string)
Parameters
| vertices | string | Element | Node | Group | Array<string | Element | Node | Group> | Either a vertex, a vertex id, or an element, or an array of any of these. |
| duration | number | Optional; defaults to 1000ms. Duration of the animation in milliseconds. |
| animName | string | Optional; the name of the CSS animation to apply. Defaults to ANIM_SURFACE_ELEMENT_FLASH. |
floatElement
Appends an element to the viewport so that it floats above the content that is being zoomed and panned. The element will have position:absolute set on it. You can float any element you like, but note that the responsibility for setting an appropriate z index is yours.
Signature
Parameters
| el | BrowserElement | Element to float. |
| pos | PointXY | Position to float the element at. This is in page coordinates, ie. it ignores the pan/zoom of the surface, and defines a position relative to the viewport's top/left corner. |
fromPageLocation
Maps the given page location to a value relative to the canvas origin, allowing for zoom and pan of the canvas.
This takes into account the offset of the canvas in the page so that what you get back is the mapped position
relative to the target element's [left,top] corner
Signature
fromPageLocation(left:number, top:number, roundValues:boolean)
Parameters
| left | number | X location |
| top | number | Y location |
| roundValues | boolean | If true, the location is returned as integers for x/y. |
fromWindowLocation
Maps the given window location to a value relative to the canvas origin. The window means the browser's visible
window, and is not the same as the page, because of scroll.
Signature
fromWindowLocation(left:number, top:number, roundValues:boolean)
Parameters
| left | number | |
| top | number | |
| roundValues | boolean | |
gather
Gather the elements in the display. If focus is provided the elements will be gathered around it. Otherwise, the elements will be gathered around the computed center of all the elements.
Signature
Parameters
| focus | string | Vertex | Optional ID of a Vertex, or the Vertex itself, around which to gather elements. |
getDecorator<T>
Gets the decorator with the given id, or null if not found.
Signature
getDecorator(id:string)
Type Parameters
Parameters
getEffectiveVisibleZoom
Gets the zoom as seen by the user, which is a function of the zoom of this surface and of any parent surface, plus any other scale transforms that may be in place in the DOM.
Signature
getEffectiveVisibleZoom()
getElementFromEvent
Get the model object + DOM element on which the given event occurred.
Signature
getElementFromEvent(e:MouseEvent)
Parameters
getGrid
Get the grid for this instance. May be null.
Signature
getGrid()
getGroupContentExtents
Compute the extents of all the child members of the given group, by default with respect to the group's origin, which effectively gives you the internal size required by the group, or, if you set relativeToCanvasOrigin, with respect to the canvas origin.
Signature
getGroupContentExtents(
group:
Group,
relativeToCanvasOrigin:
boolean)
Parameters
| group | Group | The group to find extents for |
| relativeToCanvasOrigin | boolean | Defaults to false. |
getLabelLocationAttribute
Gets the name of the attribute that is used to determine the label for the given edge.
Signature
getLabelLocationAttribute(
edge:
Edge)
Parameters
getLayout
Gets the Layout this surface is currently using.
Signature
getLayout()
getModelPositionAttributes
Returns the names of the attributes used to store positioning information in the model. Mostly an internal
method but exposed in case it proves useful to someone.
Signature
getModelPositionAttributes()
Return value
{
x:string,
y:string
}getObjectInfo<V>
Decodes the given input into a data structure containing a model object, its type, its ID, and the element used to represent it. Always returns a value even if no model object could be resolved for the given input, because in some circumstances the given input represents an element from the UI that is not in the model (such as when dragging a new edge)
Signature
Type Parameters
| V | Base | The type of object you're expecting back from the method. This is for convenience, so that the obj member of the return value is typed conveniently for what you want to do with it. |
Parameters
getPan
Gets the current origin of the panned content.
Signature
getPan()
getPath
Gets a Path from some source Vertex to some target Vertex. This method is a wrapper around the model's getPath method, adding a few ui specific functions to the result.
Signature
Parameters
getPlugin<P>
Gets the plugin registered for the given type, null if nothing matching found.
Signature
getPlugin(pluginType:string)
Type Parameters
Parameters
getRenderedConnection
Gets the underlying connection that was rendered for the Edge with the given id.
Signature
getRenderedConnection(edgeId:string)
Parameters
| edgeId | string | ID of the Edge to retrieve the Connection for. |
getRenderedElement
For some node/group, get the element that was used to render it.
Signature
getRenderedElement(
obj:
string | Base)
Parameters
getRenderedPort
Gets the DOM node that was rendered for the Port with the given id (does not retrieve vjs-endpoint elements)
Signature
getRenderedPort(
portIdOrPort:
string | Port)
Parameters
| portIdOrPort | string | Port | Either the port, or the id of the port for which to retrieve the rendered element. Note that you must supply a "full" id here, that is in dotted notation with the id of the Node/Group on which the port resides. |
getViewportBoundsInfo
Gets the current bounds information.
Signature
getViewportBoundsInfo()
getZoom
Gets the current zoom.
Signature
getZoom()
getZoomRange
Gets the current zoom range.
Signature
getZoomRange()
hasClass
Returns whether the DOM element represented by el - which can be an Edge, Connection, Node, Group, DOM element, or ID of some model object - has the given class.
Signature
hasClass(el:SupportsClassManipulationElement, clazz:string)
Parameters
| el | SupportsClassManipulationElement | |
| clazz | string | |
isDraggable
Helper method to get the draggable state of some element. Under the hood all this does is check for the
existence of the data-vjs-not-draggable attribute.
Signature
Parameters
isInViewport
Returns whether or not the given point (relative to page origin) is within the viewport for the widget.
Signature
isInViewport(x:number, y:number)
Parameters
| x | number | X location of point to test |
| y | number | Y location of point to test |
isPageLocationInViewport
Returns whether or not the given point (relative to page origin) is within the viewport for the widget.
Signature
isPageLocationInViewport(x:number, y:number)
Parameters
| x | number | X location of point to test |
| y | number | Y location of point to test |
isVisible
Returns whether or not the given model object is visible.
Signature
Parameters
load
Load the dataset and the current state of the Surface - its pan and zoom settings, as well as data for any registered data hooks.
Signature
Parameters
lockGroup
Mark a group as "locked" : edges inside of it cannot be detached, removed or have their paths edited, edges cannot be established to child vertices.
Signature
lockGroup(
groupIdOrGroup:
string | Group)
Parameters
| groupIdOrGroup | string | Group | |
magnetize
Magnetize the elements in the display. If focus is provided it will be used as the origin for magnetization,
and not moved (unless repositionFocus is true). If no focus is provided, the computed center of all the
elements will be used as the origin.
Signature
magnetize(
focus:
string | Vertex,
repositionFocus:
boolean)
Parameters
| focus | string | Vertex | |
| repositionFocus | boolean | |
magnetizeAtEvent
Magnetize the elements in the display, using the location of the given MouseEvent as the origin.
Signature
magnetizeAtEvent(event:MouseEvent)
Parameters
magnetizeAtPoint
Magnetize the elements in the display, using the given point as the origin.
Signature
Parameters
mapEventLocation
Maps the location of the given event on the page onto the coordinate space of this widget, returning a value representing where the given event appears to be with respect to the origin of the Surface's viewport.
Signature
mapEventLocation(event:MouseEvent)
Parameters
nudgeZoom
Nudges the zoom by the given amount. Zoom will be clamped to the current zoom range in effect and the value that was ultimately set is returned from this function. The value you pass in here is multiplied by 100 to give a percentage value: 1 is 100%, for instance, 0.05 is 5%.
Signature
nudgeZoom(delta:number, e:any)
Parameters
| delta | number | Amount to change zoom by. |
| e | any | Original event that caused the nudge. May be null. |
off
Remove an event binding from the given element or elements.
Signature
Parameters
| el | Document | BrowserElement | NodeListOf<BrowserElement> | Element, or elements, from which to remove the event binding. |
| event | string | Name of the event to unbind. |
| callback | Function | The function you wish to unbind. |
Bind an event listener to the given element or elements.
Signature
Parameters
| el | Document | BrowserElement | NodeListOf<BrowserElement> | Element, or elements, to bind the event listener to. |
| event | string | Name of the event to bind to. |
| callbackOrSelector | string | Function | Either a callback function, or a CSS 3 selector. When this is a selector the event listener is bound as a "delegate", ie. the event listeners listens to events on children of the given el that match the selector. |
| callback | Function | Callback function for event. Only supplied when you're binding a delegated event handler. |
pan
Pans the canvas by a given amount in X and Y.
Signature
pan(dx:number, dy:number, doNotAnimate:boolean)
Parameters
| dx | number | Amount to pan in X direction |
| dy | number | Amount to pan in Y direction |
| doNotAnimate | boolean | By default this operation uses animation. |
refresh
Refreshes the layout. For some layouts this is the same as a full relayout.
Signature
refresh(doNotRepaintConnections:boolean)
Parameters
| doNotRepaintConnections | boolean | |
registerDataHook
Register a DataHook - a pair of functions that are invoked during a load and a save. This mechanism is a means you can use for storing/retrieving custom data from the payload the UI exports: in the save method you can decorate the data provided to you with anything you like, but you must ensure that it is serializable, ie. it must be pure data. In your load method you can read out this data and take appropriate action.
Signature
Parameters
registerTag
Register a custom tag on the UI. This will only take effect if the UI is using the default VisuallyJs template
renderer.
Signature
Parameters
relayout
Runs a relayout of all vertices in the canvas, and of each group.
Signature
relayout(newParameters:any, doNotRepaintConnections:boolean)
Parameters
| newParameters | any | |
| doNotRepaintConnections | boolean | |
relayoutGroup
Relayout the given group.
Signature
relayoutGroup(
groupOrId:
string | Group,
reason:
GroupRelayoutReason)
Parameters
| groupOrId | string | Group | The group - or the ID of the group - to relayout. |
| reason | GroupRelayoutReason | |
reload
When the UI is rendering a Selection, this method triggers a reload on the selection, causing the UI to be cleared and recreated.
Signature
reload()
removeClass
Removes a class from the DOM element represented by el, which can be a Selection, or an instance of many different types - see the SupportsClassManipulation interface for a complete list.
Signature
Parameters
removeDragClassnameFilter
Removes a CSS class filter from the drag handler.
Signature
removeDragClassnameFilter(clazz:string | Array<string>)
Parameters
| clazz | string | Array<string> | Either a single class name, or a comma separated list of classnames, or an array of classnames. |
removeFromDragGroup
Removes the given element(s) from any drag group they may be in. You don't need to supply the drag group id, as elements can only be in one drag group anyway.
Signature
Parameters
repaintEdge
Repaint this edge.
Signature
Parameters
repaintEdges
Repaint this set of edges.
Signature
repaintEdges(
edges:
Array<Edge>)
Parameters
repaintEverything
Repaint every connection in the instance.
Signature
repaintEverything(doNotRefreshElements:boolean)
Parameters
| doNotRefreshElements | boolean | |
reset
Clears all connections and managed elements from the instance of the UI. Does not also clear out
event listeners, selectors, or connection types - for that, use destroy().
Signature
reset()
rotate
Rotate the given vertex by the given number of degrees. The UI element representing the vertex is rotated and the view is updated, and an event is pushed to the undo stack.
Signature
rotate(
obj:
string | Vertex,
amountInDegrees:
number)
Parameters
| obj | string | Vertex | Either a vertex ID, or a Node/Group |
| amountInDegrees | number | Amount - in degrees - to rotate. |
save
Save the dataset and the current state of the Surface - its pan and zoom settings, as well as data for any registered data hooks.
Signature
Parameters
saveToUrl
Saves the return value of this object's save method via ajax POST to a given URL.
Signature
Parameters
setApparentCanvasLocation
Sets the apparent canvas location - see the notes for getApparentCanvasLocation.
Signature
setApparentCanvasLocation(left:number, top:number)
Parameters
| left | number | Value in pixels for left edge of canvas. |
| top | number | Value in pixels for top edge of canvas. |
setClamping
Sets whether or not the widget clamps the movement of the canvas during pan/zoom to ensure that the managed content never disappears from view.
Signature
setClamping(clamping:boolean)
Parameters
| clamping | boolean | Whether or not to clamp movement. |
setDraggable
Sets whether or not the given element, or element representing the given vertex, is draggable.
Signature
Parameters
setDragGroupState
Sets the active/passive state for the given element(s) in their respective drag groups (if any). You don't need to supply the drag group id, as elements can only be in one drag group anyway.
Signature
Parameters
setEnabled
Sets whether the given vertex is enabled for connection drag/drop.
Signature
setEnabled(
v:
Vertex,
state:
boolean)
Parameters
| v | Vertex | The vertex to set enabled state for. |
| state | boolean | |
setGrid
Sets the current grid for element dragging, magnetization and group sizing.
Signature
Parameters
| grid | Grid | Grid to use. If you provide null as the value the grid will be cleared. |
setLayout<LP>
Apply the given layout to the viewport, by default refreshing the viewport afterwards.
Signature
setLayout(layoutParams:{
options:LP,
type:string
}, doNotRefresh:boolean)
Type Parameters
Parameters
| layoutParams | {
options:LP, type:string
} | Spec for the layout to set. |
| doNotRefresh | boolean | Defaults to true. Whether or not to repaint the UI after setting the layout. |
setMagnetizedPosition
Sets the position of the given node/group and runs the magnetizer, updating the UI and storing results in the model. This operation is wrapped in a transaction so if undo is called then every element affected by the magnetize is relocated.
Signature
Parameters
setMode
Sets the current mode for the surface.
Signature
Parameters
| mode | SurfaceMode | |
| doNotClearSelection | boolean | Defaults to false - when true, a mode change will not first cause the selection in the underlying model to be cleared. |
setOverlayVisible
Sets the visibility of some overlay.
Signature
Parameters
| o | Overlay<BrowserElement> | Overlay to hide or show |
| visible | boolean | If true, make the overlay visible, if false, make the overlay invisible. |
setPan
Sets the position of the panned content's origin.
Signature
setPan(
left:
number,
top:
number,
animate:
boolean,
onComplete:
(p:PointXY) => any)
Parameters
| left | number | Position in pixels of the left edge of the panned content. |
| top | number | Position in pixels of the top edge of the panned content. |
| animate | boolean | Whether or not to animate the pan. Defaults to false. |
| onComplete | (p:PointXY) => any | If animate is set to true, an optional callback for the end of the pan |
setPanAndZoom
Sets the pan and zoom for the Surface in one pass.
Signature
setPanAndZoom(x:number, y:number, zoom:number, animate:boolean)
Parameters
| x | number | Value for pan in x axis |
| y | number | Value for pan in Y axis |
| zoom | number | Value fo zoom |
| animate | boolean | Defaults to false. If true, the changes will be made with the widget animating. |
setPosition
Sets the position of some vertex and updates the model. This method will honour any grid that is currently in effect.
Signature
Parameters
| vertex | string | Node | Group | BrowserElement | Node/group id, or some node/group, or the element representing some node/group. |
| x | number | X position, in canvas coordinates, to set. |
| y | number | Y position, in canvas coordinates, to set. |
| magnetize | boolean | Whether or not to apply the magnetizer to move other vertices out of this vertex's way. |
| force | boolean | Used in conjunction with magnetize. When null, or true, the element is positioned where requested and other elements move. When false, the element is positioned as close to the requested position as possible, without moving any other elements. |
setSize
Sets the width and height of the given vertex, updating the UI and the model, and adding an event to the undo stack. NOTE this method may not have entirely the effect you want unless you have useModelForSizes set in the constructor options for this UI instance.
Signature
setSize(
obj:
string | Vertex,
width:
number,
height:
number)
Parameters
| obj | string | Vertex | |
| width | number | |
| height | number | |
setSuspendRendering
Sets whether rendering is suspended or not.
Signature
setSuspendRendering(val:boolean, thenRefresh:boolean)
Parameters
| val | boolean | |
| thenRefresh | boolean | If true, the surface will refresh after the change in state. |
setViewportCenter
Sets the location of the canvas such that the given point appears at the center of the viewport.
Signature
Parameters
| xy | PointXY | location of the point on the canvas to position in the center of the viewport. |
setVisible
Sets the visible state of some model object or group of model objects. If the object is a vertex, the visible state will be applied to all edges connected to the given vertex.
By default this method will, for groups and nodes, cascade down to any nested vertices.
Signature
Parameters
| obj | Base | FilterableDataset | ArrayLike<Node | Edge | Group | Port> | Edge, Group, Node or Port, and array of these, or a FilterableDataset, such as a Selection. |
| state | boolean | True if edges should be visible, false otherwise. |
| doNotCascade | boolean | Defaults to false. If true, don't cascade down to any nested vertices. |
setZoom
Sets the current zoom, clamping it to the allowed range. Returns the new zoom level - which may or may not be the value you asked for, as it might have been clamped to the current allowed zoom range.
Signature
setZoom(zoom:number, animate:boolean)
Parameters
| zoom | number | Zoom value. If this is outside the allowed bounds it will be clamped. |
| animate | boolean | If true, the surface will animate the transition in zoom by stepping through several intermediate levels in succession. |
setZoomRange
Sets the current zoom range. By default, this method checks if the current zoom is within the new range, and if it is not then setZoom is called, which will cause the zoom to be clamped to an allowed value in the new range. You can disable this by passing true for doNotClamp.
Signature
setZoomRange(
zr:
ZoomRange,
doNotClamp:
boolean)
Parameters
| zr | ZoomRange | New range, as an array consisting of [lower, upper] values. Lower must be less than upper. |
| doNotClamp | boolean | If true, will not check the current zoom to ensure it falls within the new range. |
snapPageLocationToGrid
Maps the given x,y to canvas coordinates via fromPageLocation, snaps that canvas location to the given grid, and then converts the snapped canvas location back to page coordinates.
Signature
snapPageLocationToGrid(
x:
number,
y:
number,
grid:
Grid)
Parameters
| x | number | X position, in page coordinates. |
| y | number | Y position, in page coordinates |
| grid | Grid | Grid to apply - in canvas coordinates. |
snapToGrid
Snaps one or all vertices to the current grid or to the grid provided to this method.
Signature
Parameters
| el | string | Vertex | BrowserElement | ID of vertex, Vertex, or DOM element representing a Vertex. |
| grid | Grid | Optional grid to snap to. If not provided, the Surface will use the grid passed in to its constructor. If that is also null, nothing will be snapped. |
startEditingPath<T>
Start editing the given edge or connection, optionally with the given edit parameters.
Signature
Type Parameters
Parameters
stopEditingPath
Stop editing any connector paths.
Signature
stopEditingPath()
storePositionsInModel
Writes the current position for each node into the data model. A common use case is to run an auto layout the
first time some dataset is seen, and then to save the locations of all the vertices once a human being has moved
things around.
Signature
storePositionsInModel(params:{
leftAttribute:string,
topAttribute:string
})
Parameters
| params | {
leftAttribute:string, topAttribute:string
} | Parameters |
toBack
Moves the specified element or vertex to the back of its parent’s children in the DOM order. Optionally moves its ancestors to the back as well.
Signature
Parameters
| v | string | Vertex | BrowserElement | The element, vertex, or browser element to be moved to the back. |
| alsoSendAncestorsToBack | boolean | If true, the ancestors of the specified element are also moved to the back. |
toFront
Brings the specified element or vertex to the front within its parent container. Optionally, this method can also ensure all ancestor elements are brought to the front.
Signature
Parameters
| v | string | Vertex | BrowserElement | The element or vertex to be brought to the front. This can be a string identifier, a Vertex object, or a BrowserElement. |
| alsoBringAncestorsToFront | boolean | Indicates whether the ancestors of the specified element should also be brought to the front. Defaults to false. |
toggleClass
Toggles a class on the DOM element represented by el, which can be a Selection, or an instance of many different types - see the SupportsClassManipulation type for a complete list.
Signature
Parameters
toggleGroup
Expand a group if it is collapsed, or collapse it if it is expanded.
Signature
toggleGroup(
group:
string | Group)
Parameters
toPageLocation
Maps the given canvas location to a page location, allowing for zoom and pan of the canvas. Note that page in this method takes scroll into account. If you wish to map to just the visible section of the browser, use toWindowLocation.
Signature
toPageLocation(left:number, top:number)
Parameters
| left | number | X location |
| top | number | Y location |
toViewportLocation
Maps the given canvas location to a point, in page coordinates, relative to the surface container's origin. A return value of [0,0] from this method indicates the top left corner of the surface's container as seen by the user; negative values for x and/or y mean that the point is not in the visible viewport. Similarly, values for x greater the container width, or y greater than the container height, indicate that the point is not in the visible viewport.
This method is useful when you want to position an element over the canvas at some specific canvas location. For instance, the SurfacePopup components use this to position themselves relative to the vertex they are currently referencing.
Signature
toViewportLocation(left:number, top:number)
Parameters
trigger
Trigger an event on the given element. Exposed for API users but mostly intended for internal use.
Signature
trigger(
el:
Document | BrowserElement,
event:
string,
originalEvent:
Event,
payload:
any,
detail:
number)
Parameters
| el | Document | BrowserElement | Element to trigger the event on. |
| event | string | Name of the event to trigger. |
| originalEvent | Event | Optional event that gave rise to this method being called. |
| payload | any | Optional payload to set on the Event that is created. |
| detail | number | Optional detail for the Event that is created. |
unbind
Unbind the given event listener, or all listeners. If you call this method with no arguments then all event listeners are unbound.
Signature
unbind(eventOrListener:string | Function, listener:Function)
Parameters
| eventOrListener | string | Function | Either an event name, or an event handler function |
| listener | Function | If eventOrListener is defined, this is the event handler to unbind. |
Return value
EventGeneratorunbindModelEvent<T>
Unbinds a listener for a model event.
Signature
Type Parameters
Parameters
unfixElement
Removes an element that was previously fixed via the fixElement method.
Signature
Parameters
unlockGroup
Unlock a group.
Signature
unlockGroup(
groupIdOrGroup:
string | Group)
Parameters
| groupIdOrGroup | string | Group | |
zoomIn
Zooms in by one step, within the allowed zoom range.
Signature
Parameters
zoomOut
Zooms out by one step, within the allowed zoom range.
Signature
Parameters
zoomToBackground
Zooms the display so that the background (if one is set) fits inside the viewport.
Signature
zoomToBackground(
params:
{
doNotAnimate:boolean,
onComplete:(p:PointXY) => any
})
Parameters
| params | {
doNotAnimate:boolean, onComplete:(p:PointXY) => any
} | |
zoomToDecorator
Zooms the display to fit the canvas and content plus any elements added by the given decorator.
Signature
zoomToDecorator(
zParams:
{
decorator:string | Decorator,
doNotAnimate:boolean,
doNotFirePanEvent:boolean,
doNotZoomIfVisible:boolean,
fill:number,
onComplete:(p:PointXY) => any,
onStep:() => any
})
Parameters
| zParams | {
decorator:string | Decorator, doNotAnimate:boolean, doNotFirePanEvent:boolean, doNotZoomIfVisible:boolean, fill:number, onComplete:(p:PointXY) => any, onStep:() => any
} | |
zoomToElements
Zooms the viewport so that all of the given elements are visible.
Signature
Parameters
zoomToExtents
Zooms the display to fit the given extents, which may be a single box or an array of boxes; in the latter case VisuallyJs will calculate a minimum bounding box for all the boxes provided.
Signature
Parameters
zoomToFit
Zooms the display so that all the tracked elements fit inside the viewport. This method will also, by default, increase the zoom if necessary - meaning the default behaviour is to adjust the zoom so that the content fills the viewport. You can suppress zoom increase by setting doNotZoomIfVisible:true on the parameters to this method.
Signature
Parameters
zoomToFitIfNecessary
Zooms the display so that all the tracked elements fit inside the viewport, but does not make any adjustments to zoom if all the elements are currently visible (it still does center the content though).
Signature
Parameters
zoomToSelection
Zooms the display so that the current selected nodes are all visible, optionally animating the transition.
Signature
Parameters
| params | {
doNotAnimate:boolean, doNotZoomIfVisible:boolean, fill:number, filter:(o:Base) => boolean | ObjectData, selection:VisuallyJsSelection
} | Optional method params |