ModelOptions
Constructor options for a VisuallyJs model instance.
| Name | Type | Description |
|---|---|---|
| beforeConnect? | BeforeConnectInterceptor | Definition of a function to use as a beforeConnect interceptor. |
| beforeDetach? | 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. |
| beforeMoveConnection? | 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. |
| beforeStartConnect? | 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. |
| beforeStartDetach? | 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 is that this method is fired as soon as a user tries to detach an edge from an endpoint in the UI, whereas allows a user to detach the edge in the UI. |
| data? | any | Data to load directly after Toolkit has been created. |
| defaultCost? | number | The default cost for an edge. Default value is 1. |
| defaultDirected? | boolean | Whether edges are directed by default. The default value for this is - edges are directed by default. |
| edgeFactory? | ObjectFactory | Optional factory method used when creating edges via the addFactoryEdge method. |
| edgeIdFunction? | 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 property. |
| edgeTypeFunction? | 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 property. |
| edgeTypeProperty? | string | The name of the property that identifies a given edge's . By default this is the property. If you do not set this but you do set , that value will be used. |
| events? | ModelEventsOptions | Optional model event mappings to bind |
| groupFactory? | ObjectFactory | Optional factory method used when creating groups via the addFactoryGroup method. |
| groupProperty? | 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? | Record<string,GroupTemplate> | Optional map of group templates to register on the model. |
| idFunction? | IdFunction | A function to use to determine the ID of some data object. By default VisuallyJs uses the value of the object's property. |
| maxSelectedEdges? | number | The maximum number of edges that can be selected at any one time. Defaults to Infinity. |
| maxSelectedGroups? | number | The maximum number of groups that can be selected at any one time. Defaults to Infinity. |
| maxSelectedNodes? | number | The maximum number of nodes that can be selected at any one time. Defaults to Infinity. |
| modelHeightAttribute? | string | The name of the property inside a vertex's data that identifies its height. Defaults to . |
| modelLeftAttribute? | string | The name of the property inside a vertex's data that identifies its location in the y axis. Defaults to . |
| modelRotationAttribute? | string | The name of the property inside a vertex's data that identifies its rotation. Defaults to . |
| modelTopAttribute? | string | The name of the property inside a vertex's data that identifies its location in the x axis. Defaults to . |
| modelWidthAttribute? | string | The name of the property inside a vertex's data that identifies its width. Defaults to . |
| nodeFactory? | ObjectFactory | Optional factory method used when creating nodes via the addFactoryNode method. |
| portDataProperty? | 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 . 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 function. |
| portExtractor? | (o:ObjectData, nodeOrGroup:Node | Group) => Array<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 . Note that if you provide the then you do not need to set this. |
| portFactory? | ObjectFactory | Optional factory method used when creating ports via the addFactoryPort method. |
| portIdFunction? | 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 property. |
| portOrderProperty? | 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 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 function. |
| portSeparator? | string | The character to use in port identifiers. Defaults to , eg. someVertex.somePort. |
| portTypeFunction? | 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 property. |
| portTypeProperty? | string | The name of the property that identifies a given port's . By default this is the property. If you do not set this but you do set , that value will be used. |
| portUpdater? | (data:ObjectData, nodeOrGroup:Node | Group, ports:Array<Port>) => 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 then you do not need to set this. |
| selectionCapacityPolicy? | 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? | SelectionMode | Optional mode for VisuallyJs's current selection. Defaults to the Selection default - . |
| typeFunction? | TypeFunction | A function to use to determine the type of some data object. By default VisuallyJs uses the value of the object's property. |
| typeProperty? | string | The name of the property that identifies a given object's . By default this is the property. |
| undoRedo? | {
enabled:boolean, maximumSize:number } | Configuration for undo/redo |