Skip to content

GraphRenderer

Unofficial

Renderer for the graph view, managing PixiJS rendering, user interactions, and layout.

Import:

import type { GraphRenderer } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface GraphRenderer

Properties

PropertyTypeDescription
colorsRecord<GraphColor, GraphColorAttributes>General colors of the elements in the graph view, computed from the app CSS.
containerElHTMLDivElement<div> element containing the graph, with class .view-content.
dragNodeGraphNode | nullNode currently being dragged, if any.
fLineSizeMultnumberFactor for the thickness of the links.
fNodeSizeMultnumberFactor for the size of the nodes.
fShowArrowbooleanIndicates if arrows should be displayed.
fTextShowMultnumberText fade threshold.
hangerContainerMain container to which nodes, links and arrows are added.
heightnumberHeight of the graph view, in pixel.
hidePowerTagbooleanWhether to hide the power tag indicator in the graph view.
highlightNodeGraphNode | nullNode currently being highlighted, if any.
idleFramesnumberNumber of idle frames. The simulation stops running at 60.
iframeElHTMLIFrameElement<iframe> element in which the graph is rendered.
interactiveElHTMLCanvasElement<canvas> element bound to the event system of GraphRenderer.px to capture events.
keyboardActionsKeyboardActionsKeyboard action bindings for graph interaction.
linksGraphLink[]List of links currently rendered.
mouseXnull | numberMouse x coordinate in the graph view.
mouseYnull | numberMouse y coordinate in the graph view.
nodeLookupRecord<string, GraphNode>Record of the nodes currently rendered, with GraphNode.id used as key.
nodesGraphNode[]List of nodes currently rendered.
nodeScalenumberScale of the nodes based on the zoom level of the graph view.
panningbooleanWhether the user is currently panning the graph view.
panvXnumberCurrent pan velocity along the x axis.
panvYnumberCurrent pan velocity along the y axis.
panXnumberCurrent pan offset along the x axis.
panYnumberCurrent pan offset along the y axis.
powerTagPowerTagPower tag configuration for the graph view.
pxApplicationPixiJS application rendering everything.
renderTimernull | numberTimer (request ID) associated to the requestAnimationFrame rendering the graph.
scalenumberCurrent zoom level of the graph view, interpolated between the previous one and the GraphRenderer.targetScale.
targetScalenumberTarget zoom level of the graph view.
textAlphanumberCurrent alpha of the nodes names based on the graph scale.
viewportCoordsCurrent visible viewport bounds of the graph view.
widthnumberWidth of the graph view, in pixel.
workerWorkerWeb Worker thread running the graph simulation.
workerResultsWorkerResultsResults received from the graph simulation worker.
zoomCenterXnumberX coordinate of the zoom action.
zoomCenterYnumberY coordinate of the zoom action.

Methods

MethodReturnsDescription
changed()voidSpecify that the renderer has changed and needs to be rendered again.
destroy()voidDestroy the renderer and release all resources.
destroyGraphics()voidDestroy all the graphics of the graph.
getBackgroundScreenshot()HTMLCanvasElementCapture a screenshot of the graph with the background included.
getHighlightNode()GraphNode | nullReturns the currently highlighted node, if any.
getTransparentScreenshot()ICanvasCapture a screenshot of the graph with a transparent background.
initGraphics()voidInitialize all the graphics of the graph.
onIframeLoad()voidCalled when the graph iframe finishes loading.
onIframeUnload()voidCalled when the graph iframe is unloaded.
onMouseMove(evt)voidHandle mouse movement over the graph view.
onNodeClick(evt, id, type)voidHandle a click on a graph node.
onNodeHover(evt, id, type)voidHandle hover over a graph node.
onNodeRightClick(evt, id, type)voidHandle a right-click on a graph node.
onNodeUnhover()voidHandle the pointer leaving a graph node.
onPointerDown(renderer, evt)voidHandle a pointer down event on the graph.
onPointerOut()voidHandle the pointer leaving the graph view.
onPointerOver(renderer, evt)voidHandle the pointer entering the graph view.
onResize()voidHandle a resize of the graph container.
onWheel(evt)voidHandle a wheel (scroll/zoom) event on the graph view.
queueRender()voidQueue a render frame to be executed on the next animation frame.
renderCallback()voidCallback invoked on each render frame.
resetPan()voidReset the pan offset to the origin.
setData(data)voidSet the graph data (nodes and links) to render.
setForces(forces)voidSet the force simulation parameters.
setPan(panX, panY)voidSet the pan offset to the given coordinates.
setRenderOptions(options)voidSet the rendering options for the graph view.
setScale(scale)voidSet the zoom scale of the graph view.
testCSS()voidRe-read CSS variables and update the graph colors accordingly.
updateZoom()voidInterpolate the current zoom level towards the target scale.
zoomTo(scale, pointer)voidZoom the graph view to the given scale, centered on the given point.

Links to this page: