reagraph
Version:
WebGL Node-based Graph for React
93 lines (92 loc) • 2.46 kB
TypeScript
import { default as ThreeCameraControls } from 'camera-controls';
import { default as Graph } from 'graphology';
import { ReactNode, default as React } from 'react';
import { CameraControlsRef, CameraMode } from '../CameraControls';
import { GraphSceneProps, GraphSceneRef } from '../GraphScene';
import { LassoType } from '../selection/Lasso';
import { Theme } from '../themes';
export interface GraphCanvasProps extends Omit<GraphSceneProps, 'theme'> {
/**
* Theme to use for the graph.
*
* @default lightTheme
*/
theme?: Theme;
/**
* Type of camera interaction.
*
* @default 'pan'
*/
cameraMode?: CameraMode;
/**
* The maximum distance for the camera.
*
* @default 50000
*/
maxDistance?: number;
/**
* The minimum distance for the camera.
*
* @default 1000
*/
minDistance?: number;
/**
* The minimum zoom level for the camera.
*
* @default 1
*/
minZoom?: number;
/**
* The maximum zoom level for the camera.
*
* @default 100
*/
maxZoom?: number;
/**
* The type of lasso selection.
*
* @default 'none'
*/
lassoType?: LassoType;
/**
* Children to render in the canvas. Useful for things like lights.
*/
children?: ReactNode;
/**
* Ability to extend Canvas gl options. For example `{ preserveDrawingBuffer: true }`
*
* @default {}
*/
glOptions?: object;
/**
* When the canvas had a lasso selection.
*/
onLasso?: (selections: string[]) => void;
/**
* When the canvas had a lasso selection end.
*/
onLassoEnd?: (selections: string[]) => void;
/**
* When the canvas was clicked but didn't hit a node/edge.
*/
onCanvasClick?: (event: MouseEvent) => void;
/**
* Whether to aggregate edges with the same source and target.
*/
aggregateEdges?: boolean;
}
export type GraphCanvasRef = Omit<GraphSceneRef, 'graph' | 'renderScene'> & Omit<CameraControlsRef, 'controls'> & {
/**
* Get the graph object.
*/
getGraph: () => Graph;
/**
* Get the camera controls.
*/
getControls: () => ThreeCameraControls;
/**
* Export the canvas as a data URL.
*/
exportCanvas: () => string;
};
export declare const GraphCanvas: React.ForwardRefExoticComponent<GraphCanvasProps & React.RefAttributes<GraphCanvasRef>>;