Skip to main content

BaseGroupComponent

This component is what you must extend in any components you create to render groups. It injects the underlying VisuallyJsService, and also provides a number of helper methods you can use to manipulate the model object that your component represents.

The vertex this component represents is available on the class as data (a plain JS object), and $data() (a signal wrapping data).

Usage​

import { Component } from "@angular/core"
import { BaseGroupComponent } from "@visuallyjs/browser-ui-angular"

@Component({
template:`<div>
<strong>{{data.label}}</strong>
<div data-vjs-group-content="true"></div>
</div>`
})
export class MyGroupComponent extends BaseGroupComponent { }

Definition​

Class Members​

NameTypeDescription
$dataWritableSignal<ObjectData>This signal represents the underlying data for the vertex this component represents.
dataObjectDataData object for the vertex
zoomWritableSignal<number>This is a signal that provides the current zoom for the canvas the component is in. You can use this to selectively hide/show content based upon the zoom level.
addNewPort(type:string, data:ObjectData)voidInstructs the model to add a new port with the given data to the vertex this component represents. This will call the model's portFactory.
addPort(data:ObjectData)PortAdds a port with the given data to the vertex this component represents.
addToSelection()voidAdds the vertex this component represents to the current selection in the model.
cloneGroup(options:SurfaceVertexCloneOptions)voidInstructs the model to clone this group - which will result in a new group being added to the UI, whose position will be shifted slightly in X and Y from the cloned group.
cloneVertex(options:SurfaceVertexCloneOptions)voidClones this vertex, optionally setting to a given position, or offsetting from the original, and optionally magnetizing the new vertex's position, and flashing it to show the user where it is.
flashGroup(duration:number, animName:string)voidFlash this Group
getGroup()GroupGets the group that this component represents.
getMembers()Array<Node>Gets the child vertices for this group. Group members may be of type Node or Group.
getPort(portId:string)PortGets the port with the given ID
getVertex()GroupGets the vertex that this component represents. Subclasses have getters that return more specific subclasses of Vertex.
removeFromSelection()voidRemoves the vertex this component represents from the current selection in the model.
removeGroup()voidShortcut method to remove the Group (and therefore this whole component)
removePort(portId:string)voidRemoves the port with the given id.
removeVertex()voidRemoves the vertex this component represents from the data model, which will cause this component to be cleaned up.
setAsSelection()voidSets the vertex this component represents as the current selection in the model.
updateGroup(data:ObjectData)voidShortcut method to update the current data backing this Group, for convenience.
updateVertex(data:ObjectData)voidShortcut method to update the current data backing this vertex, for convenience.