pivotick / Pivotick
Class: Pivotick
Defined in: Graph.ts:26
Constructors
Constructor
new Pivotick(
container,data?,options?):Graph
Defined in: Graph.ts:87
Initializes a graph inside the specified container using the provided data and options.
Parameters
container
HTMLElement
The HTMLElement that will serve as the main container for the graph.
data?
The graph data, including nodes and edges, to render.
options?
Partial<GraphOptions>
Optional configuration for the graph's behavior, UI, styling, simulation, etc.
Returns
Graph
Methods
addEdge()
addEdge(
e):Edge
Defined in: Graph.ts:1000
Adds an edge to the graph.
Both the source (from) and target (to) nodes must already exist in the graph. Throws an error if an edge with the same ID already exists.
Parameters
e
The edge to add.
Returns
Throws
Error if the edge ID already exists or if either node does not exist. Triggers onChange after the edge is successfully added.
addNode()
addNode(
n):Node
Defined in: Graph.ts:902
Adds a node to the graph.
Parameters
n
Returns
Throws
Error if a node with the same id already exists. Triggers onChange after the node is successfully added.
addNote()
addNote(
n):Note|undefined
Defined in: Graph.ts:1265
Adds a note to the graph and draws it. Takes the same options as data.notes (what Note.toJSON returns), or a Note. Emits noteAdd.
Parameters
n
Returns
Note | undefined
the note, or undefined while UI.notes.enabled is false.
Throws
Error if a note with the same id already exists.
addToSelection()
addToSelection(
nodes):void
Defined in: Graph.ts:1637
Adds nodes to the current selection, leaving what is already selected in place. Already-selected nodes are ignored.
Nodes only: the interaction layer has no additive setter for edges, which can only be selected as a whole set via selectElements.
Parameters
nodes
Node[]
The Nodes to add.
Returns
void
clearEmphasis()
clearEmphasis():
void
Defined in: Graph.ts:1726
End the emphasis emphasiseElements started: the canvas reads normally again.
Returns
void
clearForecast()
clearForecast():
void
Defined in: Graph.ts:1745
Take the forecast down.
Returns
void
clearHighlightedElements()
clearHighlightedElements():
void
Defined in: Graph.ts:1707
Remove any highligh class from any nodes or edges
Returns
void
closeTable()
closeTable():
void
Defined in: Graph.ts:1669
Closes the data dock.
Returns
void
deselectAll()
deselectAll():
void
Defined in: Graph.ts:1681
Deselect all
Returns
void
destroy()
destroy():
void
Defined in: Graph.ts:1444
Destroy all UI components.
Returns
void
edgeVisibilityChanged()
edgeVisibilityChanged():
void
Defined in: Graph.ts:1388
Repaint after an edge-layer change. Deliberately not onChange: layers don't touch the link force (see Simulation.getActiveEdges), so restarting the simulation would move the graph for no reason.
Returns
void
emphasiseElements()
emphasiseElements(
elements):void
Defined in: Graph.ts:1721
Pick a set of elements out of the graph: they keep the look they already have while everything else on the canvas dims, until clearEmphasis. This is how hovering a legend entry reads its category off the canvas.
Where highlightElement points at one element, this describes a group. Elements that aren't drawn right now are skipped, and an empty set dims nothing.
Parameters
elements
The Nodes and Edges to emphasise.
Returns
void
focusElement()
focusElement(
element):void
Defined in: Graph.ts:1583
Brings the specified node or edge into focus within the graph view. A node hidden in a closed cluster or group brings that cluster or group into focus.
Parameters
element
The Node or Edge to focus.
Returns
void
getAppID()
getAppID():
string
Defined in: Graph.ts:1456
The ID of the app
Returns
string
getConnectedNodes()
getConnectedNodes(
node):Node[]
Defined in: Graph.ts:1241
Retrieves all nodes directly connected from the given node.
Returns cloned nodes to prevent external modifications.
Parameters
node
The node or node ID to find connections from.
string | Node
Returns
Node[]
An array of Node objects directly connected from the given node.
getEdge()
getEdge(
id):Edge|undefined
Defined in: Graph.ts:1036
Retrieves an edge from the graph by its ID.
Returns a deep clone of the edge to prevent external mutations.
Parameters
id
string
The ID of the edge.
Returns
Edge | undefined
A cloned Edge if found, otherwise undefined.
getEdgeCount()
getEdgeCount():
number
Defined in: Graph.ts:1086
Returns the number of edges currently in the graph.
Returns
number
The total edge count.
getEdges()
getEdges():
Edge[]
Defined in: Graph.ts:1168
Retrieves all edges in the graph.
Returns clones of the edges to prevent external modifications.
Returns
Edge[]
An array of cloned Edge objects.
getEdgesFromNode()
getEdgesFromNode(
node):Edge[]
Defined in: Graph.ts:1211
Finds all edges originating from a given node.
Returns cloned edges to prevent external modifications.
Parameters
node
The node or node ID to find outgoing edges from.
string | Node
Returns
Edge[]
An array of Edge objects whose from node matches the query.
getEdgesToNode()
getEdgesToNode(
node):Edge[]
Defined in: Graph.ts:1226
Finds all edges pointing to a given node.
Returns cloned edges to prevent external modifications.
Parameters
node
The node or node ID to find incoming edges to.
string | Node
Returns
Edge[]
An array of Edge objects whose to node matches the query.
getGraphDepth()
getGraphDepth():
number
Defined in: Graph.ts:1566
Returns
number
getMutableEdge()
getMutableEdge(
id):Edge|undefined
Defined in: Graph.ts:1052
Retrieves an edge from the graph by its ID.
Returns the actual edge instance, allowing direct modifications.
Warning: Directly modifying edges using this method may lead to unexpected behavior. It is generally safer to use getEdge which returns a cloned instance.
Parameters
id
string
The ID of the edge.
Returns
Edge | undefined
The Edge if found, otherwise undefined.
getMutableEdges()
getMutableEdges():
Edge[]
Defined in: Graph.ts:1184
Retrieves all edges in the graph.
Returns the actual edge instances, allowing direct modifications.
Returns
Edge[]
An array of Edge objects.
Remarks
⚠️ Warning: Modifying edges directly may lead to unexpected behavior. Use getEdges instead to work with safe clones.
getMutableNode()
getMutableNode(
id):Node|undefined
Defined in: Graph.ts:943
Retrieves a node from the graph by its ID.
Returns the actual node instance, allowing direct modifications.
Warning: Directly modifying nodes using this method may lead to unexpected behavior. It is generally safer to use getNode which returns a cloned instance.
Parameters
id
The ID of the node or a Node object.
string | Node
Returns
Node | undefined
The Node if found, otherwise undefined.
getMutableNodes()
getMutableNodes():
Node[]
Defined in: Graph.ts:1114
Retrieves all nodes in the graph.
Returns the actual node instances, allowing direct modifications.
Returns
Node[]
An array of Node objects.
Remarks
⚠️ Warning: Modifying nodes directly may lead to unexpected behavior. It is generally safer to use getNodes, which returns cloned instances.
getMutableVisibleEdges()
getMutableVisibleEdges():
Edge[]
Defined in: Graph.ts:1199
Retrieves all visible edges in the graph.
Returns the actual edge instances, allowing direct modifications.
Returns
Edge[]
An array of Edge objects.
Remarks
⚠️ Warning: Modifying edges directly may lead to unexpected behavior. Use getEdges instead to work with safe clones.
getMutableVisibleNodes()
getMutableVisibleNodes():
Node[]
Defined in: Graph.ts:1130
Retrieves all visible nodes in the graph. Recursively adding visible children
Returns the actual node instances, allowing direct modifications.
Returns
Node[]
An array of Node objects.
Remarks
⚠️ Warning: Modifying nodes directly may lead to unexpected behavior. It is generally safer to use getNodes, which returns cloned instances.
getNode()
getNode(
id):Node|undefined
Defined in: Graph.ts:927
Retrieves a node from the graph by its ID.
Returns a deep clone of the node to prevent external mutations.
Parameters
id
The ID of the node or a Node object.
string | Node
Returns
Node | undefined
A cloned Node if found, otherwise undefined.
getNodeCount()
getNodeCount():
number
Defined in: Graph.ts:1077
Returns the number of nodes currently in the graph.
Returns
number
The total node count.
getNodes()
getNodes():
Node[]
Defined in: Graph.ts:1097
Retrieves all nodes in the graph.
Returns clones of the nodes to prevent external modifications.
Returns
Node[]
An array of cloned Node objects.
getNote()
getNote(
id):Note|undefined
Defined in: Graph.ts:1254
Parameters
id
string
Returns
Note | undefined
getNotes()
getNotes():
Note[]
Defined in: Graph.ts:1250
Returns
Note[]
getOptions()
getOptions():
GraphOptions
Defined in: Graph.ts:693
Returns the current configuration options of the graph.
Returns
hideNode()
hideNode(
node):void
Defined in: Graph.ts:1393
Parameters
node
Returns
void
highlightElement()
highlightElement(
element):void
Defined in: Graph.ts:1690
Add a highligh class to the given node or edge
Parameters
element
The Node or Edge to highligh.
Returns
void
nextTick()
nextTick():
void
Defined in: Graph.ts:1430
Trigger the next render update of the graph.
Returns
void
nextTickFor()
nextTickFor(
nodes):void
Defined in: Graph.ts:1437
Trigger the next render update of the graph for the passed subjects.
Parameters
nodes
Node[]
Returns
void
noteAdd()
noteAdd(
note):void
Defined in: Graph.ts:422
Parameters
note
Returns
void
noteChange()
noteChange(
note):void
Defined in: Graph.ts:425
Parameters
note
Returns
void
noteRemove()
noteRemove(
note):void
Defined in: Graph.ts:428
Parameters
note
Returns
void
off()
off<
K>(event,handler):void
Defined in: Graph.ts:258
Type Parameters
K
K extends keyof GraphEvents
Parameters
event
K
handler
GraphEvents[K]
Returns
void
on()
on<
K>(event,handler):void
Defined in: Graph.ts:251
Type Parameters
K
K extends keyof GraphEvents
Parameters
event
K
handler
GraphEvents[K]
Returns
void
openTable()
openTable():
void
Defined in: Graph.ts:1662
Opens the data dock — the graph's rows as a sortable, selectable grid split off the bottom of the canvas. full mode only, and only when UI.table allows it; a no-op otherwise.
The dock can hold panes other than the table now, so this also brings the table's pane to the front: the call is named for the table and should show you one. Reach for UIManager.dock or activateDockTab() to drive the region without that.
Returns
void
removeBySource()
removeBySource(
source):object
Defined in: Graph.ts:592
Remove everything a source vouches for. An element several sources vouch for survives, one claim lighter — the same uniform rule pivot undo follows, and the only way anything a pivot brought is removed.
It is a forward operation, and one entry in history: undoing it puts back what left and hands the source's claim back to what stayed.
Parameters
source
string
A pivot id, or 'seed' for data that was never pivoted.
Returns
object
What was actually removed.
edges
edges:
Edge[]
nodes
nodes:
Node[]
removeEdge()
removeEdge(
id):void
Defined in: Graph.ts:1062
Removes an edge from the graph by its ID.
Parameters
id
string
The ID of the edge to remove. Triggers onChange after the edge is removed.
Returns
void
removeFromSelection()
removeFromSelection(
nodes):void
Defined in: Graph.ts:1648
Removes nodes from the current selection, leaving the rest of it in place. Nodes only, on the same terms as addToSelection.
Parameters
nodes
Node[]
The Nodes to remove.
Returns
void
removeNode()
removeNode(
id):void
Defined in: Graph.ts:969
Removes a node from the graph by its ID.
Also removes any edges connected to the node.
Parameters
id
string
The ID of the node to remove. Triggers onChange after the node and its edges are removed.
Returns
void
selectElement()
selectElement(
element):void
Defined in: Graph.ts:1593
Selects a given node or edge in the graph. A node hidden in a closed cluster or group is still the one selected; the canvas lights the cluster or group drawn for it.
Parameters
element
The Node or Edge to select.
Returns
void
selectElements()
selectElements(
elements):void
Defined in: Graph.ts:1610
Selects several nodes, or several edges, replacing the current selection — the plural selectElement, resolving each element's rendered handle for you.
Nodes and edges cannot be selected together (the interaction layer clears one kind when the other is set), so a mixed array selects the nodes and warns.
Parameters
elements
The Nodes or Edges to select. An empty array clears the selection.
Returns
void
setData()
setData(
nodes,edges,notes):void
Defined in: Graph.ts:852
Replaces all current nodes and edges in the graph with the provided data. Clears existing nodes and edges before setting the new ones. Triggers the onChange callback after the update.
Parameters
nodes
Node[] = []
Array of nodes to set. Defaults to an empty array.
edges
Edge[] = []
Array of edges to set. Defaults to an empty array.
notes
Note[] = []
Returns
void
setLegend()
setLegend(
config?):void
Defined in: Graph.ts:450
Replace the canvas legend at runtime — the imperative twin of UI.legend. A graph that started without one gets it built on the spot; false empties the legend and drops its filter, and true / undefined fall back to deriving one from render.nodeTypeAccessor. Pass a LegendGroupOptions to key the graph on several dimensions at once.
Parameters
config?
The legend to show, or false to remove it.
boolean | LegendOptions | LegendGroupOptions
Returns
void
setNotes()
setNotes(
notes):Note[]
Defined in: Graph.ts:1282
Replaces the graph's notes, leaving nodes and edges alone. Notes are matched by id: one already on the canvas is updated in place, so its drawing stays bound to it, one not in notes is removed, and a new one is added.
Parameters
notes
(Note | NoteOptions)[]
Returns
Note[]
the notes now on the graph, in the order given.
Throws
Error if two entries share an id. Nothing is changed then.
setVisibleNodes()
setVisibleNodes(
nodes,notify):boolean
Defined in: Graph.ts:1356
Returns whether anything moved, so an edge-only filter change can repaint itself. notify is off for the query engine's first pass, which runs before anything is drawn — the constructor's own simulation.update() / renderer.init() follow it.
Parameters
nodes
Node[]
notify
boolean = true
Returns
boolean
showForecast()
showForecast(
forecast):void
Defined in: Graph.ts:1740
Paint what an action would do, and change nothing else: the elements it would take away drain in place, the ones it would hide with them, and whatever it would bring back is outlined where it would land.
Where emphasiseElements reads a set out of the canvas by receding the rest, a forecast answers "what happens if I click" — so the graph has to keep reading normally around the few elements that would change. graph.history.preview(...) returns one ready-made.
Parameters
forecast
Returns
void
showNode()
showNode(
node):void
Defined in: Graph.ts:1404
Parameters
node
Returns
void
toggleExpandNode()
toggleExpandNode(
node):void
Defined in: Graph.ts:1415
Parameters
node
Returns
void
toggleExpandNodes()
toggleExpandNodes(
nodes):void
Defined in: Graph.ts:1420
Parameters
nodes
Node[]
Returns
void
toggleTable()
toggleTable():
void
Defined in: Graph.ts:1674
Opens the data dock if it is closed, closes it if it is open.
Returns
void
unHighlightElement()
unHighlightElement(
element):void
Defined in: Graph.ts:1699
Remove a highligh class to the given node or edge
Parameters
element
The Node or Edge to select.
Returns
void
updateData()
updateData(
newNodes?,newEdges?,triggerChangeEvent?):void
Defined in: Graph.ts:764
Updates the graph with new nodes and/or edges.
An id the graph already holds is updated in place: what the element is — its data, style and weight — becomes what you handed over, while the object itself keeps its identity. It has to work that way. Its edges, the simulation and the DOM binding all hold that object, and so does everything it has learned since it was built: which sources vouch for it, where it sits, whether it is pinned. A position on the incoming element still wins, so updateData can move something as well as refresh it. Unknown ids are added.
A container's children are not restructured here — pass the container through removeNode and addNode to change what it holds.
The whole call is one batch: one dataBatchChanged listing every add and change in the order given, then one re-render, however many elements it carries.
Parameters
newNodes?
Node[]
Optional array of nodes to update or add.
newEdges?
Edge[]
Optional array of edges to update or add.
triggerChangeEvent?
boolean = true
Announce the in-place changes. Adds are announced either way.
Returns
void
use()
use(
plugin):this
Defined in: Graph.ts:246
Install a PivotickPlugin. Can be called at any time — the plugin's UI elements are caught up to the current lifecycle phase. Returns this for chaining.
Parameters
plugin
Returns
this
Properties
editing
readonlyediting:GraphEditingManager
Defined in: Graph.ts:45
history
readonlyhistory:GraphHistory
Defined in: Graph.ts:57
What the canvas holds and shows, and how it came to: every ingest, deletion, durable hide and hand-drawn element, contiguously reversible. Bounded and session-scoped — it does not survive a reload.
i18n
readonlyi18n:I18n
Defined in: Graph.ts:68
The language this graph writes its own text in, from GraphOptions.i18n: message lookup, plurals, and number, list and sort formats. A nested graph shares its parent's.
noteManager
noteManager:
NoteManager
Defined in: Graph.ts:31
notifier
notifier:
Notifier
Defined in: Graph.ts:32
pivots
readonlypivots:PivotManager
Defined in: Graph.ts:51
The pivot runtime: register enrichments, run them, triage what they return, and undo a whole run. Lives on Graph rather than the UI because pivots produce data — and because it has to exist before the UI is built.
queryEngine
queryEngine:
GraphQueryEngine
Defined in: Graph.ts:35
renderer
renderer:
GraphRenderer
Defined in: Graph.ts:33
simplify
readonlysimplify:Simplification
Defined in: Graph.ts:62
Folds nodes that play the same role into one group drawn in their place. The groups are view state: getNodes(), getEdges(), the table and the history see the members.
simulation
simulation:
Simulation
Defined in: Graph.ts:34