@graphty/graphty-element / session / VisibilityApi
Interface: VisibilityApi ​
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:168
Hiding part of the graph, and saying how much is left.
Properties ​
edges ​
readonlyedges:ReadonlySet<string>
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:206
The visible edge ids, on the same terms as VisibilityApi.nodes.
filter ​
readonlyfilter:RuleTree|null
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:210
The filter in force, or null when no filter is hiding anything.
nodes ​
readonlynodes:ReadonlySet<NodeId>
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:204
The visible node ids, materialised lazily from the mask.
Identity-stable and genuinely read-only: the same object comes back until the membership changes, so previous === next is a valid staleness test. A consumer that only needs membership should call VisibilityApi.isVisible, which allocates nothing.
showContext ​
showContext:
boolean
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:260
Whether hidden nodes should still be drawn faintly instead of vanishing.
A reader who hides nine tenths of a graph usually still wants to see the shape of what they hid. The flag is owned here because it is part of what "visible" means to a consumer, and it is honoured by the renderer, which draws the hidden nodes as a low-alpha point layer. Turning it on changes NOTHING about the masks: a context node is still hidden, still outside every run's default scope, and still absent from nodes. Changing it is one undoable step.
summary ​
readonlysummary:VisibilitySummary
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:208
How much of the graph is showing.
window ​
readonlywindow:TimeWindow|null
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:212
The time window in force, or null when no window is hiding anything.
Methods ​
edgeMask() ​
edgeMask():
Uint8Array
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:186
The visible edges, as one byte per edge.
An edge is visible only when BOTH its endpoints are visible; an edge filter can narrow the set further but can never put back an edge whose endpoint is hidden.
Returns ​
Uint8Array
The bytes, one per edge in the graph.
isVisible() ​
isVisible(
id):boolean
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:196
Whether one element is visible.
The id is read as a NODE id first and as an EDGE id only when the graph holds no such node, because an edge is addressed by its two endpoints joined with a colon and a node is not. An element the graph does not hold is not visible.
Parameters ​
id ​
The node or edge id.
Returns ​
boolean
True when the element is part of the visible data scope.
nodeMask() ​
nodeMask():
Uint8Array
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:178
The visible nodes, as one byte per node.
A DETACHED COPY of the live bytes, so it can be transferred to a worker without leaving the session holding a dead array. Indexed by the dense node index, 1 for visible.
This is the DATA scope. The renderer may draw fewer nodes than are set here.
Returns ​
Uint8Array
The bytes, one per node in the graph.
set() ​
set(
filter,options?):Run<FilterResult>
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:235
Apply a filter, or clear it with null.
One undoable step: the filter is recorded at once (filter reads it as soon as this returns), and the masks are evaluated on the next pass against whatever filter is in force then, so a slider dragged through sixty values evaluates the last one, not all sixty, and the drag is one step. The run settles once that pass has run, with the counts it left.
A signal already aborted when this is called writes nothing. A cancel() or an abort after the call does NOT take the filter back -- it has been recorded, and may have merged into a larger step -- so session.undo() is the way back.
The time window is untouched. The two compose.
Of the run options, signal and onProgress are honoured; queue is not, and dryRun is REFUSED rather than ignored -- plan({ op: "visibility.set", filter }) is the call that answers "what would this leave showing" without doing it.
Parameters ​
filter ​
RuleTree | null
What to keep, or null to stop filtering.
options? ​
A signal to cancel with, and a progress handler.
Returns ​
The run, which resolves with the counts.
Throws ​
A GraphtyError when the filter is malformed or needs something this session lacks.
setWindow() ​
setWindow(
window,options?):Run<FilterResult>
Defined in: graphty-element/src/session/visibility/VisibilityApi.ts:249
Apply a time window, or clear it with null: one undoable step, on the same terms as VisibilityApi.set.
The SAME masks as VisibilityApi.set, produced the same way, composed with whatever filter is in force. Moving the window never re-layouts, rebuilds or removes data, which is a structural fact here rather than a promise: a window writes bytes into a mask, and positions are somewhere else entirely.
Parameters ​
window ​
TimeWindow | null
The stretch of the timeline to keep, or null to stop windowing.
options? ​
A signal to cancel with, and a progress handler.
Returns ​
The run, which resolves with the counts.
Throws ​
A GraphtyError when the window is malformed or needs something this session lacks.