Creates a new Graph.
The graph schema.
Optional
options: {The graph configuration. Optional.
Optional
adjustVertices?: anyIf true, multiple edges connected between two nodes will be spaced apart.
Optional
contextMenuItems?: any[]The context menu items to add to the graph.
Optional
defaultStyles?: anyUsed to override the graph's default styling. Check ./constants.js for a full list of style properties.
Optional
dom?: HTMLElementIf supplied, the graph will be attached to this element.
Optional
edgeHoverEffect?: booleanWhether the graph should show an edge highlight effect when the mouse is hovering over edges. Optional. Defaults to true.
Optional
incrementNodeNames?: booleanWhether the graph should increment the node name when a node with the same name already exists. Optional. Defaults to false.
Optional
initialData?: anyThe graph data to initialize the graph with.
Optional
passiveUIEvents?: booleanIf true, the graph will not update its data and view upon user interaction. Instead, these interactions can be handled explicitly by listening to fired events. Optional. Defaults to false.
Optional
readOnly?: booleanWhether the graph is read only. Optional. Defaults to false.
Optional
restrictTranslate?: booleanWhether the graph should restrict the translate graph operation to the graph area. Optional. Defaults to false.
The current graph data. Contains an object with any nodes and edges present in the graph. This can be passed into the graph constructor to reload the current graph.
Add an edge to the graph.
The edge to add.
The edge id for the new edge.
Add a node to the graph.
The node to add.
Delete an edge from the graph.
The edge to delete.
Delete a node from the graph.
The node to delete.
Deselect the currently selected item in the graph.
Destroy the graph. Clears the graph from the DOM and removes all event listeners associated with the graph.
Get the current center position of the viewport in the graph.
The current center position of the viewport in the graph as an object containing x and y.
Get the current scale of the graph.
The current scale of the graph.
Convert a position in window space to a position in graph space.
A position in the window, as an object containing x and y.
The position in the graph based on the given window position, as an object containing x and y.
Add an event listener to the graph.
The name of the event to listen for.
The callback to call when the event is triggered.
Select an edge in the current graph.
The edge to select
The edge id of the edge to select
Select a node in the current graph.
The node to select
Set the center of the viewport to the given position.
The x position to set the center of the viewport to.
The y position to set the center of the viewport to.
Set the scale of the graph.
The new scale of the graph.
Set the error state of a node attribute.
The node to update.
The name of the attribute to update.
Whether the attribute should be set in the error state.
Update the value of an attribute of a node.
The node to update.
The name of the attribute to update.
The new value for the attribute.
Update the position of a node.
The node to add.
The new position, given as an object containing x and y properties.
Update the type of a node.
The node to update.
The new type for the node.
Represents a new Graph.