Skip to content

Web Component API Reference

Complete API reference for the <graphty-element> Web Component.

Overview

The Graphty class is a Lit-based Web Component that provides declarative graph visualization through HTML attributes and element properties.

TIP

For usage patterns and examples, see the Web Component Guide.

Properties

The Web Component exposes these properties for declarative configuration:

Data Properties

PropertyAttributeTypeDescription
nodeDatanode-dataArray<object>Array of node objects
edgeDataedge-dataArray<object>Array of edge objects
nodeIdPathnode-id-pathstringJMESPath to node ID (default: "id")
edgeSrcIdPathedge-src-id-pathstringJMESPath to edge source ID (default: "src")
edgeDstIdPathedge-dst-id-pathstringJMESPath to edge destination ID (default: "dst")

Layout Properties

PropertyAttributeTypeDescription
layoutlayoutstringLayout algorithm name
layoutConfiglayout-configobjectLayout algorithm options

Display Properties

PropertyAttributeTypeDescription
viewModeview-mode'2d' | '3d' | 'vr' | 'ar'Rendering mode
styleTemplatestyle-templateobjectStyle configuration

Data Source Properties

PropertyAttributeTypeDescription
dataSourcedata-sourcestringData source type
dataSourceConfigdata-source-configobjectData source configuration

XR Properties

PropertyAttributeTypeDescription
xr-XRConfigVR/AR configuration

Debug Properties

PropertyAttributeTypeDescription
enableDetailedProfilingenable-detailed-profilingbooleanEnable performance profiling
runAlgorithmsOnLoadrun-algorithms-on-loadbooleanAuto-run style template algorithms

Methods

The Web Component provides these methods for imperative control:

View Mode

MethodParametersReturnsDescription
getViewMode()-ViewModeGet current view mode
setViewMode(mode)mode: ViewModePromise<void>Set view mode
isVRSupported()-Promise<boolean>Check VR availability
isARSupported()-Promise<boolean>Check AR availability

Screenshot & Video

MethodParametersReturnsDescription
captureScreenshot(options?)ScreenshotOptionsPromise<ScreenshotResult>Capture screenshot
canCaptureScreenshot(options?)ScreenshotOptionsPromise<CapabilityCheck>Check screenshot support
captureAnimation(options)AnimationOptionsPromise<AnimationResult>Capture video
cancelAnimationCapture()-booleanCancel ongoing capture
isAnimationCapturing()-booleanCheck if capturing
estimateAnimationCapture(options)AnimationOptionsPromise<CaptureEstimate>Estimate capture

Camera Control

MethodParametersReturnsDescription
getCameraState()-CameraStateGet camera state
setCameraState(state, options?)CameraState, CameraAnimationOptionsPromise<void>Set camera state
setCameraPosition(pos, options?){x, y, z}, CameraAnimationOptionsPromise<void>Set camera position (3D)
setCameraTarget(target, options?){x, y, z}, CameraAnimationOptionsPromise<void>Set camera target (3D)
setCameraZoom(zoom, options?)number, CameraAnimationOptionsPromise<void>Set zoom (2D)
setCameraPan(pan, options?){x, y}, CameraAnimationOptionsPromise<void>Set pan (2D)
resetCamera(options?)CameraAnimationOptionsPromise<void>Reset to default

Camera Presets

MethodParametersReturnsDescription
saveCameraPreset(name)stringvoidSave current state as preset
loadCameraPreset(name, options?)string, CameraAnimationOptionsPromise<void>Load preset
getCameraPresets()-Record<string, CameraState>Get all presets
exportCameraPresets()-Record<string, CameraState>Export user presets as JSON
importCameraPresets(presets)Record<string, CameraState>voidImport presets from JSON

Graph Access

PropertyTypeDescription
graphGraphAccess the underlying Graph instance

Events

The Web Component emits standard DOM events:

typescript
element.addEventListener('graph-settled', (e) => {
  console.log('Layout complete');
});

element.addEventListener('node-click', (e) => {
  console.log('Clicked:', e.detail.node.id);
});

See the Events Guide for the complete event reference.

Generated Reference

For complete type definitions and detailed API documentation: