GraphLinksModels support links between nodes and grouping nodes and links into subgraphs. GraphLinksModels hold node data and link data in separate arrays. Node data is normally represented in a Diagram by instances of Node, but they could be represented by simple Parts or by Groups. Link data should be represented by instances of Link.
This constructs an empty GraphLinksModel unless one provides arguments as the initial data array values for the Model#nodeDataArray and GraphLinksModel#linkDataArray properties.
an optional Array containing JavaScript objects to be represented by Nodes.
an optional Array containing JavaScript objects to be represented by Links.
Gets or sets a data object that will be copied and added to the model as a new node data each time there is a link reference (either the "to" or the "from" of a link data) to a node key that does not yet exist in the model.
Gets or sets a function that makes a copy of a link data object.
Gets or sets a function that makes a copy of a node data object.
Gets or sets the name of the format of the diagram data.
Gets or sets whether this model may be modified, such as adding nodes.
Gets or sets the name of the data property that returns a string describing that data's category, or a function that takes a link data object and returns that category string; the default value is the name 'category'.
Gets or sets the array of link data objects that correspond to Links in the Diagram.
Gets or sets the name of the data property that returns the key of the node data that the link data is coming from, or a function that takes a link data object and returns that key; the default value is the name 'from'. The name must not be null. If the value is an empty string,
Gets or sets the name of the data property that returns the optional parameter naming a "port" element on the node that the link data is connected from, or a function that takes a link data object and returns that string.
Gets or sets the name of the data property that returns an array of keys of node data that are labels on that link data, or a function that takes a link data object and returns such an array; the default value is the empty string: ''.
Gets or sets the name of the data property that returns the key of the node data that the link data is going to, or a function that takes a link data object and returns that key; the default value is the name 'to'.
Gets or sets the name of the data property that returns the optional parameter naming a "port" element on the node that the link data is connected to, or a function that takes a link data object and returns that string.
Gets or sets a function that returns a unique id number or string for a node data object.
Gets or sets the name of this model.
Gets or sets the name of the node data property that returns a string describing that data's category, or a function that takes a node data object and returns the category name; the default value is the name 'category'.
Gets or sets the array of node data objects that correspond to Nodes, Groups, or non-Link Parts in the Diagram.
Gets or sets the name of the property on node data that specifies the string or number key of the group data that "owns" that node data, or a function that takes a node data object and returns that group key.
Gets or sets the name of the boolean property on node data that indicates whether the data should be represented as a group of nodes and links or as a simple node, or a function that takes a node data object and returns true or false; the default value is the name 'isGroup'.
Gets or sets the name of the boolean property on node data that indicates whether the data should be represented as a node acting as a label on a link instead of being a regular node, or a function that takes a node data object and returns true or false; the default value is the empty string: ''.
Gets or sets the name of the data property that returns a unique id number or string for each node data object, or a function taking a node data object and returning the key value; the default value is the name 'key'.
Gets or sets whether ChangedEvents are not recorded by the UndoManager.
Gets or sets the UndoManager for this Model.
Add an item at the end of a data array that may be data bound by a Panel as its Panel#itemArray, in a manner that can be undone/redone and that automatically updates any bindings. This also calls #raiseChangedEvent to notify all listeners about the ChangedEvent#Insert. If you want to add a new node or part to the diagram, call #addNodeData.
an Array that is the value of some Panel's Panel#itemArray.
the new value to be pushed onto the array.
any
Register an event handler that is called when there is a ChangedEvent. This registration does not raise a ChangedEvent.
a function that takes a ChangedEvent as its argument.
any
Adds a node key value that identifies a node data acting as a new label node on the given link data. This method only works if #linkLabelKeysProperty has been set to something other than an empty string.
a JavaScript object representing a link.
a number or string that is the key of the new label node.
any
When you want to add a link to the diagram, call this method with a new data object. This will add that data to the #linkDataArray and notify all listeners that a new link data object has been inserted into the collection. Presumably the link data object will already have its "from" and "to" node key references set, but it is also possible to set them after the link data is in the model by calling #setFromKeyForLinkData and #setToKeyForLinkData. This operation does nothing if the link data is already part of this model's #linkDataArray.
a JavaScript object representing a link.
any
When you want to add a node or group to the diagram, call this method with a new data object. This will add that data to the #nodeDataArray and notify all listeners that a new node data object has been inserted into the collection. To remove a node from the diagram, you can remove its data object by calling #removeNodeData. To add or remove an object or value from an item array, call #insertArrayItem or #removeArrayItem.
a JavaScript object representing a node, group, or non-link.
any
Clear out all references to any model data.
any
Commit the changes of the current transaction. This just calls UndoManager#commitTransaction.
a descriptive name for the transaction.
boolean
Decide if a given link data is in this model.
a JavaScript object representing a link.
boolean
Decide if a given node data is in this model.
a JavaScript object representing a node, group, or non-link.
boolean
Gets or sets a function that makes a copy of a link data object. You may need to set this property in order to ensure that a copied Link is bound to data that does not share certain data structures between the original link data and the copied link data. The value may be null in order to cause #copyLinkData to make a shallow copy of a JavaScript Object. The default value is null.
Object
Make a copy of a node data object. This uses the value of #copyNodeDataFunction to actually perform the copy, unless it is null, in which case this method just makes a shallow copy of the JavaScript Object. This does not modify the model -- the returned data object is not added to this model. This assumes that the data's constructor can be called with no arguments.
a JavaScript object representing a node, group, or non-link.
Object
Given a number or string, find the node data in this model that uses the given value as its unique key.
a string or a number.
Object
Find the category of a given link data, a string naming the link template that the Diagram should use to represent the link data.
a JavaScript object representing a link.
string
Find the category of a given node data, a string naming the node template or group template or part template that the Diagram should use to represent the node data.
a JavaScript object representing a node, group, or non-link.
string
From a link data retrieve a value uniquely identifying the node data from which this link is connected.
a JavaScript object representing a link.
any
From a link data retrieve a value identifying the port object of the node from which this link is connected.
a JavaScript object representing a link.
string
If there is a container group for the given node data, return the group's key.
a JavaScript object representing a node, group, or non-link.
any
Given a node data object return its unique key: a number or a string. It is possible to change the key for a node data object by calling #setKeyForNodeData.
a JavaScript object representing a node, group, or non-link.
any
Gets an Array of node key values that identify node data acting as labels on the given link data. This method only works if #linkLabelKeysProperty has been set to something other than an empty string.
a JavaScript object representing a link.
Array<any>
From a link data retrieve a value uniquely identifying the node data to which this link is connected.
a JavaScript object representing a link.
any
From a link data retrieve a value identifying the port object of the node to which this link is connected.
a JavaScript object representing a link.
string
Add an item to a data array that may be data bound by a Panel as its Panel#itemArray, given a new data value and the index at which to insert the new value, in a manner that can be undone/redone and that automatically updates any bindings. This also calls #raiseChangedEvent to notify all listeners about the ChangedEvent#Insert. If you want to add a new node or part to the diagram, call #addNodeData.
an Array that is the value of some Panel's Panel#itemArray.
the zero-based array index where the new value will be inserted; use -1 to push the new value on the end of the array.
the new value to be inserted into the array.
any
See if the given node data should be represented as a group or as a simple node.
This value must not change as long as the node data is part of the model.
At the current time there is no setIsGroupForNodeData
method.
a JavaScript object representing a node, group, or non-link.
boolean
See if the given node data should act as a label on a link, in order to support
the appearance and behavior of having links connected to links.
This value must not change as long as the node data is part of the model.
At the current time there is no setIsLinkLabelForNodeData
method.
a JavaScript object representing a node, group, or non-link.
boolean
This method is called when a node data object is added to the model to make sure that
The key value should be unique within the set of data managed by this model:
If the key is already in use, this will assign an unused number to the
If you want to customize the way in which node data gets a unique key, you can set the #makeUniqueKeyFunction functional property. If the node data object is already in the model and you want to change its key value, call #setKeyForNodeData and give it a new unique key value.
a JavaScript object representing a node, group, or non-link.
any
Call this method to notify that the model or its objects have changed. This constructs a ChangedEvent and calls all Changed listeners.
specifies the general nature of the change; typically the value is ChangedEvent#Property.
names the property that was modified, or a function that takes an Object and returns the property value.
the object that was modified, typically a GraphObject, Diagram, or a Model.
the previous or older value.
the next or newer value.
an optional value that helps describe the older value.
an optional value that helps describe the newer value.
any
Call this method to notify about a data property having changed value. This constructs a ChangedEvent and calls all Changed listeners. You should call this method only if the property value actually changed. This method is called by #setDataProperty.
the data object whose property changed value.
the name of the property, or a function that takes an Object and returns the property value.
the previous or old value for the property.
the next or new value for the property.
an optional value additionally describing the old value.
an optional value additionally describing the new value.
any
Remove an item from a data array that may be data bound by a Panel as its Panel#itemArray, given the index at which to remove a data value, in a manner that can be undone/redone and that automatically updates any bindings. This also calls #raiseChangedEvent to notify all listeners about the ChangedEvent#Remove. If you want to remove a node from the diagram, call #removeNodeData. Note that there is no version of this method that takes an item value instead of an index into the array. Because item arrays may hold any JavaScript value, including numbers and strings, there may be duplicate entries with that value in the array. To avoid ambiguity, removing an item from an array requires an index.
an Array that is the value of some Panel's Panel#itemArray.
the zero-based array index of the data item to be removed from the array; if not supplied it will remove the last item of the array.
any
Unregister an event handler listener. This deregistration does not raise a ChangedEvent.
a function that takes a ChangedEvent as its argument.
any
Removes a node key value that identifies a node data acting as a former label node on the given link data. Removing a reference to a node data from the collection of link label keys does not automatically remove any node data from the model. This method only works if #linkLabelKeysProperty has been set to something other than an empty string.
a JavaScript object representing a link.
a number or string that is the key of the label node being removed from the link.
any
When you want to remove a link from the diagram, call this method with an existing link data object. This will remove that data from the #linkDataArray and notify all listeners that a link data object has been removed from the collection. Removing a link data from a model does not automatically remove any associated label node data from the model. This operation does nothing if the link data is not present in the #linkDataArray.
a JavaScript object representing a link.
any
When you want to remove a node or group from the diagram, call this method with an existing data object. This will remove that data from the #nodeDataArray and notify all listeners that a node data object has been removed from the collection. Removing a node data from a model does not automatically remove any connected link data from the model. Removing a node data that represents a group does not automatically remove any member node data or link data from the model. To add a node to the diagram, you can add its data object by calling #addNodeData. To add or remove an object or value from an item array, call #insertArrayItem or #removeArrayItem.
a JavaScript object representing a node, group, or non-link.
any
Rollback the current transaction, undoing any recorded changes.
boolean
Change the category of a given link data, a string naming the link template that the Diagram should use to represent the link data. Changing the link template for a link data will cause the existing Link to be removed from the Diagram} and replaced with a new Link created by copying the new link template and applying any data-bindings.
a JavaScript object representing a link.
Must not be null.
any
Change the category of a given node data, a string naming the node template or group template or part template that the Diagram should use to represent the node data. Changing the node template for a node data will cause the existing Node, Group, or Part to be replaced with a new Node, Group, or Part created by copying the new node template and applying any data-bindings.
a JavaScript object representing a node, group, or non-link.
Must not be null.
any
a JavaScript object representing a node, group, or non-link.
a string that is not null or the empty string.
the new value for the property.
any
Change the node key that the given link data references as the source of the link.
a JavaScript object representing a link.
This may be undefined if the link should no longer come from any node.
any
Change the information that the given link data uses to identify the particular "port" that the link is coming from.
a JavaScript object representing a link.
This may be the empty string if the link should no longer be associated with any particular "port".
any
Change the container group for the given node data, given a key for the new group.
a JavaScript object representing a node, group, or non-link.
This may be undefined if there should be no containing group data.
any
Change the unique key of a given node data that is already in this model. The new key value must be unique -- i.e. not in use by another node data object. You can call #findNodeDataForKey to check if a proposed new key is already in use. This operation will check all data objects in the model and replace all references using the old key value with the new one. If this is called on a node data object that is not (yet) in this model, this unconditionally modifies the property to the new key value.
a JavaScript object representing a node, group, or non-link.
any
Replaces an Array of node key values that identify node data acting as labels on the given link data. This method only works if #linkLabelKeysProperty has been set to something other than an empty string.
a JavaScript object representing a link.
an Array of node keys; an empty Array if the property was not present.
any
Change the node key that the given link data references as the destination of the link.
a JavaScript object representing a link.
This may be undefined if the link should no longer go to any node.
any
Change the information that the given link data uses to identify the particular "port" that the link is going to.
a JavaScript object representing a link.
This may be the empty string if the link should no longer be associated with any particular "port".
any
Begin a transaction, where the changes are held by a Transaction object in the UndoManager. This just calls UndoManager.startTransaction.
a descriptive name for the transaction.
boolean
Generate a string representation of the persistent data in this model, in JSON format. Object properties whose names start with "_" are not written out. Functions are not able to be written in JSON format, so any properties that have function values will not be saved in the JSON string. There must not be any circular references within the model data. Any sharing of object references will be lost in the written JSON.
The optional name of the model class to use in the output; for the standard models, this is their class name prefixed with "go.".
string
Find a Part corresponding to the given data and call its Panel#updateTargetBindings method, in each Diagram that uses this Model.
The data object in this model that was modified.
If not present or the empty string, update all bindings on the target Part or item Panel; otherwise update only those bindings using this source property name.
any