ModelOptions
Constructor options for a VisuallyJs model instance.
Properties
beforeConnect?
optionalbeforeConnect:BeforeConnectInterceptor
Definition of a function to use as a beforeConnect interceptor.
Param
The source vertex for the new edge
Param
The target vertex for the new edge
Param
If true, the new edge came from user activity, with a pointer device or touch input. This will be
false whenever the edge is added programmatically, either during a data load or via the addEdge method of VisuallyJsModel.
beforeDetach?
optionalbeforeDetach:BeforeDetachInterceptor
A function to run before the given edge is detached from the given source vertex. If this method returns false, the detach will be aborted.
Param
Edge's source.
Param
Candidate target for the edge
Param
The edge that is being detached.
beforeMoveConnection?
optionalbeforeMoveConnection:BeforeMoveConnectionInterceptor
A function to run before an edge of the given type is relocated from its current source or target to a new source or target. Returning false from this method will abort the move.
Param
Candidate source. May be the edge's current source, or may be a new source.
Param
Candidate target. May be the edge's current target, or may be a new target.
Param
The edge that is being moved.
beforeStartConnect?
optionalbeforeStartConnect:BeforeStartConnectInterceptor
A function to run before an edge of the given type is dragged from the given source. Returning false from this method will abort the connection.
Param
Param
beforeStartDetach?
optionalbeforeStartDetach:BeforeStartDetachInterceptor
A function to run before the given edge is detached from the given source vertex. If this method returns false, the detach will be aborted. The difference between this and beforeDetach is that this method is fired as soon as a user tries to detach an edge from an endpoint in the UI, whereas beforeDetach allows a user to detach the edge in the UI.
Param
Param
data?
optionaldata:any
Data to load directly after Toolkit has been created.
defaultCost?
optionaldefaultCost:number
The default cost for an edge. Default value is 1.
defaultDirected?
optionaldefaultDirected:boolean
Whether edges are directed by default. The default value for this is true - edges are directed by default.
edgeFactory?
optionaledgeFactory:ObjectFactory
Optional factory method used when creating edges via the addFactoryEdge method.
edgeIdFunction?
optionaledgeIdFunction:IdFunction
A function to use to determine the ID of some edge from its data. By default VisuallyJs uses the value of the object's id property.
edgeTypeFunction?
optionaledgeTypeFunction:TypeFunction
A function to use to determine the type of some edge from its data object. By default VisuallyJs uses the value of the object's type property.
edgeTypeProperty?
optionaledgeTypeProperty:string
The name of the property that identifies a given edge's type. By default this is the type property. If you do not set this but you do set typeProperty, that value will be used.
events?
optionalevents:ModelEventsOptions
Optional model event mappings to bind
groupFactory?
optionalgroupFactory:ObjectFactory
Optional factory method used when creating groups via the addFactoryGroup method.
groupProperty?
optionalgroupProperty:string
The name of the property inside nodes/groups that identifies their parent group. This defaults to "group" but can be changed if it clashes with your data model.
groupTemplates?
optionalgroupTemplates:Record<string,GroupTemplate>
Optional map of group templates to register on the model.
idFunction?
optionalidFunction:IdFunction
A function to use to determine the ID of some data object. By default VisuallyJs uses the value of the object's id property.
maxSelectedEdges?
optionalmaxSelectedEdges:number
The maximum number of edges that can be selected at any one time. Defaults to Infinity.
maxSelectedGroups?
optionalmaxSelectedGroups:number
The maximum number of groups that can be selected at any one time. Defaults to Infinity.
maxSelectedNodes?
optionalmaxSelectedNodes:number
The maximum number of nodes that can be selected at any one time. Defaults to Infinity.
modelHeightAttribute?
optionalmodelHeightAttribute:string
The name of the property inside a vertex's data that identifies its height. Defaults to height.
modelLeftAttribute?
optionalmodelLeftAttribute:string
The name of the property inside a vertex's data that identifies its location in the y axis. Defaults to top.
modelRotationAttribute?
optionalmodelRotationAttribute:string
The name of the property inside a vertex's data that identifies its rotation. Defaults to rotation.
modelTopAttribute?
optionalmodelTopAttribute:string
The name of the property inside a vertex's data that identifies its location in the x axis. Defaults to left.
modelWidthAttribute?
optionalmodelWidthAttribute:string
The name of the property inside a vertex's data that identifies its width. Defaults to width.
nodeFactory?
optionalnodeFactory:ObjectFactory
Optional factory method used when creating nodes via the addFactoryNode method.
portDataProperty?
optionalportDataProperty:string
The name of a property that will exist inside the backing data for nodes/group, and which represents a list of ports pertaining to that node/group. When a node/group is rendered, if this property is set, VisuallyJs will consider the value of this property to be a list of port data objects. So this property's value should be of type Array<ObjectData>. Note that this mechanism is fine for models where either all vertex types that have ports have them keyed with the same property, or you only have a single vertex type with ports, but for more advanced setups you should look at the portExtractor function.
portExtractor()?
optionalportExtractor: (o,nodeOrGroup) =>ObjectData[]
A function to use to extract an array of ports from the data representing some node/group. Whenever a node/group is rendered, VisuallyJs will use this method, if provided, to determine a list of ports for that node/group. If you use this you probably also want to define a portUpdater. Note that if you provide the portDataProperty then you do not need to set this.
Parameters
o
nodeOrGroup
Returns
portFactory?
optionalportFactory:ObjectFactory
Optional factory method used when creating ports via the addFactoryPort method.
portIdFunction?
optionalportIdFunction:IdFunction
A function to use to determine the ID of some port from its data. By default VisuallyJs uses the value of the object's id property.
portOrderProperty?
optionalportOrderProperty:string
The name of a property inside of each port's data that can be used to order the ports. For instance, you might have ports that have a rank property, which is a number. VisuallyJs will sort the ports according to the natural ordering of this property. Note that this mechanism is fine for models where either all vertex types that have ports have them keyed with the same property, or you only have a single vertex type with ports, but for more advanced setups you should look at the portUpdated function.
portSeparator?
optionalportSeparator:string
The character to use in port identifiers. Defaults to ., eg. someVertex.somePort.
portTypeFunction?
optionalportTypeFunction:TypeFunction
A function to use to determine the type of some port from its data object. By default VisuallyJs uses the value of the object's type property.
portTypeProperty?
optionalportTypeProperty:string
The name of the property that identifies a given port's type. By default this is the type property. If you do not set this but you do set typeProperty, that value will be used.
portUpdater()?
optionalportUpdater: (data,nodeOrGroup,ports) =>ObjectData
A function to use to update a given node/group's list of ports. This function should return a Javascript object which represents the node/group's backing data. This method is invoked whenever changes to some vertex's ports occur.
Note that if you provide the portDataProperty then you do not need to set this.
Parameters
data
nodeOrGroup
ports
Port[]
Returns
selectionCapacityPolicy?
optionalselectionCapacityPolicy:string
Defines the action taken when appending an object that would take the selection above its limit for the given object type. This can be either Selection.DISCARD_EXISTING (the default) or Selection.DISCARD_NEW.
selectionMode?
optionalselectionMode:SelectionMode
Optional mode for VisuallyJs's current selection. Defaults to the Selection default - SelectionModes.mixed.
typeFunction?
optionaltypeFunction:TypeFunction
A function to use to determine the type of some data object. By default VisuallyJs uses the value of the object's type property.
typeProperty?
optionaltypeProperty:string
The name of the property that identifies a given object's type. By default this is the type property.
undoRedo?
optionalundoRedo:object
Configuration for undo/redo
enabled?
optionalenabled:boolean
Whether or not undo/redo is enabled. Defaults to true.
maximumSize?
optionalmaximumSize:number
Maximum size of the undo stack. Defaults to 50.