import { D3BrushEvent } from 'd3-brush'; import { D3DragEvent } from 'd3-drag'; import { D3ZoomEvent, ZoomTransform } from 'd3-zoom'; import { Selection } from 'd3-selection'; import { ElkShape } from 'elkjs'; import { GraphDataModel } from '../../data-models/graph'; import { ComponentConfigInterface } from '../../core/component/config'; import { FitMode, TrimMode } from '../../types/text'; import { Spacing } from '../../types/spacing'; import { GraphInputLink, GraphInputNode, GraphInputData } from '../../types/graph'; import { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from '../../types/accessor'; import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape, GraphDagreLayoutSetting, GraphNode, GraphLink, GraphNodeSelectionHighlightMode, GraphFitViewAlignment } from './types'; export interface GraphConfigInterface extends ComponentConfigInterface { /** Zoom level constraints. Default: [0.35, 1.25] */ zoomScaleExtent?: [number, number]; /** Disable zooming. Default: `false` */ disableZoom?: boolean; /** Custom Zoom event filter to better control which actions should trigger zooming. * Learn more: https://d3js.org/d3-zoom#zoom_filter. * Default: `undefined` */ zoomEventFilter?: (event: PointerEvent) => boolean; /** Disable node dragging. Default: `false` */ disableDrag?: boolean; /** Disable brush for multiple node selection. Default: `false` */ disableBrush?: boolean; /** Interval to re-render the graph when zooming. Default: `100` */ zoomThrottledUpdateNodeThreshold?: number; /** Padding for the graph when fitting to container. Default: `50` */ fitViewPadding?: Spacing | number; /** Default alignment when fitting the graph view. Default: `GraphFitViewAlignment.Center` */ fitViewAlign?: GraphFitViewAlignment; /** Type of the graph layout. Default: `GraphLayoutType.Force` */ layoutType?: GraphLayoutType | string; /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */ layoutAutofit?: boolean; /** Tolerance constant defining whether the graph should be fitted to container * (on data or config update, or container resize) after a zoom / pan interaction or not. * `0` — Stop fitting after any pan or zoom * `Number.POSITIVE_INFINITY` — Always fit * Default: `8.0` */ layoutAutofitTolerance?: number; /** Place non-connected nodes at the bottom of the graph. Default: `false` */ layoutNonConnectedAside?: boolean; /** Node group accessor function. * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts. * Default: `node => node.group` */ layoutNodeGroup?: StringAccessor; /** Order of the layout groups. * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts. * Default: `[]` */ layoutGroupOrder?: string[]; /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is * `GraphLayoutType.ParallelHorizontal`). * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `6` */ layoutParallelNodesPerColumn?: number; /** Node sub-group accessor function. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `node => node.subgroup` */ layoutParallelNodeSubGroup?: StringAccessor; /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `1` */ layoutParallelSubGroupsPerRow?: number; /** Spacing between nodes, dynamic by default. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `undefined` */ layoutParallelNodeSpacing?: number | [number, number]; /** Spacing between sub-groups. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `40` */ layoutParallelSubGroupSpacing?: number; /** Spacing between groups. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `undefined` */ layoutParallelGroupSpacing?: number; /** Set a group by name to have priority in sorting the graph links. * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts. * Default: `undefined` */ layoutParallelSortConnectionsByGroup?: string; /** Force Layout settings, see the `d3-force` package for more details */ forceLayoutSettings?: GraphForceLayoutSettings; /** Darge Layout settings, see the `dagrejs` package * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout */ dagreLayoutSettings?: GraphDagreLayoutSetting; /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs. * If you want to specify custom layout option for each node group, you can provide an accessor function that * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing * layout options. Default: `undefined` */ layoutElkSettings?: GenericAccessor | undefined; /** Array of accessor functions to define nested node groups for the ELK Layered layout. * E.g.: `[n => n.group, n => n.subGroup]`. * Default: `undefined` */ layoutElkNodeGroups?: StringAccessor[]; /** A function to be called per graph node to get the ELK shape object. * This enables you to provide custom node dimensions (through the `width` and `height` properties) * and coordinates (through the `x` and `y` properties) if needed. * Default: `undefined` */ layoutElkGetNodeShape?: (d: GraphNode, i: number) => ElkShape; /** Link width accessor function ot constant value. Default: `1` */ linkWidth?: NumericAccessor; /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */ linkStyle?: GenericAccessor; /** Link band width accessor function or constant value. Default: `0` */ linkBandWidth?: NumericAccessor; /** Link arrow accessor function or constant value. Default: `undefined` */ linkArrow?: GenericAccessor | undefined; /** Link stroke color accessor function or constant value. Default: `undefined` */ linkStroke?: ColorAccessor; /** Link disabled state accessor function or constant value. Default: `false` */ linkDisabled?: BooleanAccessor; /** Link flow animation accessor function or constant value. Default: `false` */ linkFlow?: BooleanAccessor; /** Animation duration of the flow (traffic) circles in milliseconds. If `linkFlowParticleSpeed` is provided, * this duration will be calculated based on the link length and particle speed. Default: `20000` */ linkFlowAnimDuration?: NumericAccessor; /** Size of the moving particles that represent traffic flow. Default: `2` */ linkFlowParticleSize?: NumericAccessor; /** Speed of the moving particles in pixels per second. This property takes precedence over `linkFlowAnimDuration`. Default: `undefined` */ linkFlowParticleSpeed?: NumericAccessor; /** Link label accessor function or constant value. Default: `undefined` */ linkLabel?: GenericAccessor | undefined; /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */ linkLabelShiftFromCenter?: BooleanAccessor; /** Spacing between neighboring links. Default: `8` */ linkNeighborSpacing?: number; /** Curvature of the link. Recommended value range: [0:1.5]. * `0` - straight line, * `1` - nice curvature, * `1.5` - very curve. * Default: `0` */ linkCurvature?: NumericAccessor; /** Highlight links on hover. Default: `true` */ linkHighlightOnHover?: boolean; /** Offset [x,y] in pixels from the source node's center point where the link should start. Default: `undefined` */ linkSourcePointOffset?: GenericAccessor<[number, number], GraphLink>; /** Offset [x,y] in pixels from the target node's center point where the link should end. Default: `undefined` */ linkTargetPointOffset?: GenericAccessor<[number, number], GraphLink>; /** Set selected link by its unique id. Default: `undefined` */ selectedLinkId?: number | string; /** Node size accessor function or constant value. Default: `30` */ nodeSize?: NumericAccessor; /** Node stroke width accessor function or constant value. Default: `3` */ nodeStrokeWidth?: NumericAccessor; /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */ nodeShape?: GenericAccessor; /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */ nodeGaugeValue?: NumericAccessor; /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */ nodeGaugeFill?: ColorAccessor; /** Animation duration of the node gauge outline. Default: `1500` */ nodeGaugeAnimDuration?: number; /** Node central icon accessor function or constant value. Default: `node => node.icon` */ nodeIcon?: StringAccessor; /** Node central icon size accessor function or constant value. Default: `undefined` */ nodeIconSize?: NumericAccessor; /** Node label accessor function or constant value. Default: `node => node.label` */ nodeLabel?: StringAccessor; /** Defines whether to trim the node labels or not. Default: `true` */ nodeLabelTrim?: BooleanAccessor; /** Node label trimming mode. Default: `TrimMode.Middle` */ nodeLabelTrimMode?: GenericAccessor; /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */ nodeLabelTrimLength?: NumericAccessor; /** Node label fit mode: `FitMode.Trim` or `FitMode.Wrap`. The trim settings apply only in `FitMode.Trim` mode. Default: `FitMode.Trim` */ nodeLabelFitMode?: GenericAccessor; /** Maximum node label width in pixels for wrapping when the fit mode is `FitMode.Wrap`. When not provided, a width derived from the node size will be used. Default: `undefined` */ nodeLabelWidth?: NumericAccessor; /** Node label text wrapping separator. String or array of strings. Default: `undefined` */ nodeLabelSeparator?: string | string[]; /** Force word break for node labels when they don't fit. Default: `false` */ nodeLabelForceWordBreak?: boolean; /** Node sub-label accessor function or constant value: Default: `''` */ nodeSubLabel?: StringAccessor; /** Defines whether to trim the node sub-labels or not. Default: `true` */ nodeSubLabelTrim?: BooleanAccessor; /** Node sub-label trimming mode. Default: `TrimMode.Middle` */ nodeSubLabelTrimMode?: GenericAccessor; /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */ nodeSubLabelTrimLength?: NumericAccessor; /** Node sub-label fit mode: `FitMode.Trim` or `FitMode.Wrap`. The trim settings apply only in `FitMode.Trim` mode. Default: `FitMode.Trim` */ nodeSubLabelFitMode?: GenericAccessor; /** Maximum node sub-label width in pixels for wrapping when the fit mode is `FitMode.Wrap`. When not provided, a width derived from the node size will be used. Default: `undefined` */ nodeSubLabelWidth?: NumericAccessor; /** Node sub-label text wrapping separator. String or array of strings. Default: `undefined` */ nodeSubLabelSeparator?: string | string[]; /** Force word break for node sub-labels when they don't fit. Default: `false` */ nodeSubLabelForceWordBreak?: boolean; /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */ nodeSideLabels?: GenericAccessor; /** Node bottom icon accessor function. Default: `undefined` */ nodeBottomIcon?: StringAccessor; /** Node disabled state accessor function or constant value. Default: `false` */ nodeDisabled?: BooleanAccessor; /** Node fill color accessor function or constant value. Default: `node => node.fill` */ nodeFill?: ColorAccessor; /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */ nodeStroke?: ColorAccessor; /** Sorting function to determine node placement. Default: `undefined` */ nodeSort?: ((a: N, b: N) => number); /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */ nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined; /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */ nodeEnterScale?: NumericAccessor | undefined; /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */ nodeExitPosition?: GenericAccessor<[number, number], N> | undefined; /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */ nodeExitScale?: NumericAccessor | undefined; /** Custom "enter" function for node rendering. Default: `undefined` */ nodeEnterCustomRenderFunction?: (datum: GraphNode, nodeGroupElementSelection: Selection, null, unknown>, config: GraphConfigInterface, duration: number, zoomLevel: number) => void; /** Custom "update" function for node rendering. Default: `undefined` */ nodeUpdateCustomRenderFunction?: (datum: GraphNode, nodeGroupElementSelection: Selection, null, unknown>, config: GraphConfigInterface, duration: number, zoomLevel: number) => void; /** Custom partial "update" function for node rendering which will be triggered after the following events: * - Full node update (`nodeUpdateCustomRenderFunction`); * - Background click; * - Node and Link mouseover and mouseout; * - Node brushing, * Default: `undefined` */ nodePartialUpdateCustomRenderFunction?: (datum: GraphNode, nodeGroupElementSelection: Selection, null, unknown>, config: GraphConfigInterface, duration: number, zoomLevel: number) => void; /** Custom "exit" function for node rendering. Default: `undefined` */ nodeExitCustomRenderFunction?: (datum: GraphNode, nodeGroupElementSelection: Selection, null, unknown>, config: GraphConfigInterface, duration: number, zoomLevel: number) => void; /** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */ nodeOnZoomCustomRenderFunction?: (datum: GraphNode, nodeGroupElementSelection: Selection, null, unknown>, config: GraphConfigInterface, zoomLevel: number) => void; /** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */ nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode; /** Set selected node by unique id. Default: `undefined` */ selectedNodeId?: number | string; /** Set selected nodes by unique id. Default: `undefined` */ selectedNodeIds?: number[] | string[]; /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */ panels?: GraphPanelConfig[] | undefined; /** Graph node drag start callback function. Default: `undefined` */ onNodeDragStart?: (n: GraphNode, event: D3DragEvent, unknown>) => void | undefined; /** Graph node drag callback function. Default: `undefined` */ onNodeDrag?: (n: GraphNode, event: D3DragEvent, unknown>) => void | undefined; /** Graph node drag end callback function. Default: `undefined` */ onNodeDragEnd?: (n: GraphNode, event: D3DragEvent, unknown>) => void | undefined; /** Zoom event callback. Default: `undefined` */ onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent | undefined, transform: ZoomTransform) => void; /** Zoom start event callback. Default: `undefined` */ onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent | undefined, transform: ZoomTransform) => void; /** Zoom end event callback. Default: `undefined` */ onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent | undefined, transform: ZoomTransform) => void; /** Callback function to be called when the graph layout is calculated. Default: `undefined` */ onLayoutCalculated?: (nodes: GraphNode[], links: GraphLink[]) => void; /** Graph node selection brush callback function. Default: `undefined` */ onNodeSelectionBrush?: (selectedNodes: GraphNode[], event: D3BrushEvent | undefined) => void; /** Graph multiple node drag callback function. Default: `undefined` */ onNodeSelectionDrag?: (selectedNodes: GraphNode[], event: D3DragEvent, unknown>) => void; /** Callback function to be called when the graph rendering is complete. Default: `undefined` */ onRenderComplete?: (g: Selection, nodes: GraphNode[], links: GraphLink[], config: GraphConfigInterface, duration: number, zoomLevel: number, width: number, height: number) => void; /** Determines whether the component should update when new data is provided. * This function takes the previous and new data as parameters and returns a boolean * indicating whether the update should proceed. Useful for fine-grained control over * update behavior when your data has a complex nested structure. * By default the `isEqual` function from Unovis will be used to do the comparison. */ shouldDataUpdate?: (prevData: GraphInputData, nextData: GraphInputData, datamodel: GraphDataModel, GraphLink>) => boolean; } export declare const GraphDefaultConfig: GraphConfigInterface;