@unovis/ts 1.4.2-beta.0 → 1.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/axis/config.d.ts +2 -0
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.js +16 -17
- package/components/axis/index.js.map +1 -1
- package/components/brush/index.js +4 -4
- package/components/brush/index.js.map +1 -1
- package/components/brush/style.d.ts +44 -1
- package/components/brush/style.js +39 -32
- package/components/brush/style.js.map +1 -1
- package/components/graph/config.d.ts +10 -13
- package/components/graph/config.js +2 -2
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +3 -13
- package/components/graph/index.js +63 -173
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.js +14 -6
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/index.js +2 -2
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +4 -3
- package/components/graph/modules/node/index.js +63 -34
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/node/style.d.ts +0 -2
- package/components/graph/modules/node/style.js +4 -34
- package/components/graph/modules/node/style.js.map +1 -1
- package/components/graph/style.d.ts +0 -1
- package/components/graph/style.js +1 -22
- package/components/graph/style.js.map +1 -1
- package/components/graph/types.d.ts +0 -1
- package/components/graph/types.js.map +1 -1
- package/components/tooltip/config.d.ts +7 -1
- package/components/tooltip/config.js +2 -0
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.d.ts +11 -1
- package/components/tooltip/index.js +160 -44
- package/components/tooltip/index.js.map +1 -1
- package/components/tooltip/style.d.ts +5 -1
- package/components/tooltip/style.js +29 -25
- package/components/tooltip/style.js.map +1 -1
- package/containers/single-container/index.js +1 -0
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/index.js +1 -0
- package/containers/xy-container/index.js.map +1 -1
- package/core/container/index.d.ts +1 -0
- package/core/container/index.js +5 -4
- package/core/container/index.js.map +1 -1
- package/data-models/graph.d.ts +0 -2
- package/data-models/graph.js +0 -6
- package/data-models/graph.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types/text.d.ts +2 -0
- package/types/text.js.map +1 -1
- package/utils/text.d.ts +1 -1
- package/utils/text.js +27 -15
- package/utils/text.js.map +1 -1
|
@@ -3,7 +3,7 @@ import { TrimMode } from '../../types/text.js';
|
|
|
3
3
|
import { GraphLayoutType, GraphLinkStyle, GraphNodeShape } from './types.js';
|
|
4
4
|
|
|
5
5
|
// Config
|
|
6
|
-
const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, disableDrag: false,
|
|
6
|
+
const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, disableDrag: false, zoomThrottledUpdateNodeThreshold: 100, layoutType: GraphLayoutType.Force, layoutAutofit: true, layoutAutofitTolerance: 8.0, layoutNonConnectedAside: false, layoutGroupOrder: [], layoutParallelSubGroupsPerRow: 1, layoutParallelNodesPerColumn: 6, layoutParallelGroupSpacing: undefined, layoutParallelSortConnectionsByGroup: undefined, layoutNodeGroup: (n) => n.group, layoutParallelNodeSubGroup: (n) => n.subgroup, forceLayoutSettings: {
|
|
7
7
|
linkDistance: 60,
|
|
8
8
|
linkStrength: 0.45,
|
|
9
9
|
charge: -500,
|
|
@@ -14,7 +14,7 @@ const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfi
|
|
|
14
14
|
}, dagreLayoutSettings: {
|
|
15
15
|
rankdir: 'BT',
|
|
16
16
|
ranker: 'longest-path',
|
|
17
|
-
}, layoutElkSettings: undefined, layoutElkNodeGroups: undefined, linkFlowAnimDuration: 20000, linkFlowParticleSize: 2, linkWidth: 1, linkStyle: GraphLinkStyle.Solid, linkBandWidth: 0, linkArrow: undefined, linkStroke: undefined, linkFlow: false, linkLabel: undefined, linkLabelShiftFromCenter: true, linkNeighborSpacing: 8, linkDisabled: false, linkCurvature: 0, selectedLinkId: undefined, nodeGaugeAnimDuration: 1500, nodeSize: 30, nodeStrokeWidth: 3, nodeShape: GraphNodeShape.Circle, nodeGaugeValue: 0, nodeIcon: (n) => n.icon, nodeIconSize: undefined, nodeLabel: (n) => n.label, nodeLabelTrim: true, nodeLabelTrimLength: 15, nodeLabelTrimMode: TrimMode.Middle, nodeSubLabel: '', nodeSubLabelTrim: true, nodeSubLabelTrimLength: 15, nodeSubLabelTrimMode: TrimMode.Middle, nodeSideLabels: undefined, nodeBottomIcon: undefined, nodeDisabled: false, nodeFill: (n) => n.fill, nodeGaugeFill: undefined, nodeStroke: (n) => n.stroke, nodeEnterPosition: undefined, nodeEnterScale: 0.75, nodeExitPosition: undefined, nodeExitScale: 0.75, nodeSort: undefined, selectedNodeId: undefined,
|
|
17
|
+
}, layoutElkSettings: undefined, layoutElkNodeGroups: undefined, linkFlowAnimDuration: 20000, linkFlowParticleSize: 2, linkWidth: 1, linkStyle: GraphLinkStyle.Solid, linkBandWidth: 0, linkArrow: undefined, linkStroke: undefined, linkFlow: false, linkLabel: undefined, linkLabelShiftFromCenter: true, linkNeighborSpacing: 8, linkDisabled: false, linkCurvature: 0, selectedLinkId: undefined, nodeGaugeAnimDuration: 1500, nodeSize: 30, nodeStrokeWidth: 3, nodeShape: GraphNodeShape.Circle, nodeGaugeValue: 0, nodeIcon: (n) => n.icon, nodeIconSize: undefined, nodeLabel: (n) => n.label, nodeLabelTrim: true, nodeLabelTrimLength: 15, nodeLabelTrimMode: TrimMode.Middle, nodeSubLabel: '', nodeSubLabelTrim: true, nodeSubLabelTrimLength: 15, nodeSubLabelTrimMode: TrimMode.Middle, nodeSideLabels: undefined, nodeBottomIcon: undefined, nodeDisabled: false, nodeFill: (n) => n.fill, nodeGaugeFill: undefined, nodeStroke: (n) => n.stroke, nodeEnterPosition: undefined, nodeEnterScale: 0.75, nodeExitPosition: undefined, nodeExitScale: 0.75, nodeSort: undefined, selectedNodeId: undefined, panels: undefined, onNodeDragStart: undefined, onNodeDrag: undefined, onNodeDragEnd: undefined, onZoom: undefined, onLayoutCalculated: undefined, onRenderComplete: undefined });
|
|
18
18
|
|
|
19
19
|
export { GraphDefaultConfig };
|
|
20
20
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent } from 'd3-zoom'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n} from './types'\n\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Disable brush for multiple node selection. Default: `false` */\n disableBrush?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel, L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /**\n * @deprecated Use `selectedNodeIds` instead for single or multiple node selection.\n * Set selected node by unique id. Default: `undefined`\n */\n selectedNodeId?: number | string;\n /** Set selected nodes by unique id. Default: `undefined` */\n selectedNodeIds?: number[] | string[];\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (n: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Graph node selection brush callback function. Default: `undefined` */\n onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;\n /** Graph multiple node drag callback function. Default: `undefined` */\n onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n disableDrag: false,\n disableBrush: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n selectedLinkId: undefined,\n nodeGaugeAnimDuration: 1500,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n\n selectedNodeId: undefined,\n selectedNodeIds: undefined,\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onLayoutCalculated: undefined,\n onNodeSelectionBrush: undefined,\n onNodeSelectionDrag: undefined,\n}\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent } from 'd3-zoom'\nimport { Selection } from 'd3-selection'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n} from './types'\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel, L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Custom \"enter\" function for node rendering. Default: `undefined` */\n nodeEnterCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElement: SVGGElement, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"update\" function for node rendering. Default: `undefined` */\n nodeUpdateCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElement: SVGGElement, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"exit\" function for node rendering. Default: `undefined` */\n nodeExitCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElement: SVGGElement, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (n: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Callback function to be called when the graph rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n g: Selection<SVGGElement, unknown, null, undefined>,\n nodes: GraphNode<N, L>[],\n links: GraphLink<N, L>[],\n config: GraphConfigInterface<N, L>,\n duration: number,\n zoomLevel: number\n ) => void;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n disableDrag: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n selectedLinkId: undefined,\n nodeGaugeAnimDuration: 1500,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n\n selectedNodeId: undefined,\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onLayoutCalculated: undefined,\n onRenderComplete: undefined,\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -12,6 +12,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
12
12
|
}, GraphConfigInterface<N, L>> {
|
|
13
13
|
static selectors: {
|
|
14
14
|
root: string;
|
|
15
|
+
graphGroup: string;
|
|
15
16
|
background: string;
|
|
16
17
|
node: string;
|
|
17
18
|
nodeShape: string;
|
|
@@ -36,18 +37,18 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
36
37
|
protected _defaultConfig: GraphConfigInterface<N, L>;
|
|
37
38
|
config: GraphConfigInterface<N, L>;
|
|
38
39
|
datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>;
|
|
39
|
-
private
|
|
40
|
+
private _selectedNode;
|
|
40
41
|
private _selectedLink;
|
|
41
42
|
private _graphGroup;
|
|
42
43
|
private _panelsGroup;
|
|
43
44
|
private _linksGroup;
|
|
44
45
|
private _nodesGroup;
|
|
45
|
-
private _brush;
|
|
46
46
|
private _timer;
|
|
47
47
|
private _isFirstRender;
|
|
48
48
|
private _prevWidth;
|
|
49
49
|
private _prevHeight;
|
|
50
50
|
private _shouldRecalculateLayout;
|
|
51
|
+
private _currentLayoutType;
|
|
51
52
|
private _layoutCalculationPromise;
|
|
52
53
|
private _shouldFitLayout;
|
|
53
54
|
private _shouldSetPanels;
|
|
@@ -59,8 +60,6 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
59
60
|
private _scale;
|
|
60
61
|
private _initialTransform;
|
|
61
62
|
private _isDragging;
|
|
62
|
-
private _brushBehavior;
|
|
63
|
-
private _groupDragInit;
|
|
64
63
|
events: {
|
|
65
64
|
[x: string]: {
|
|
66
65
|
click: () => void;
|
|
@@ -76,9 +75,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
76
75
|
mouseout: (d: GraphLink<N, L>) => void;
|
|
77
76
|
};
|
|
78
77
|
};
|
|
79
|
-
/** @deprecated Use selectedNodes instead */
|
|
80
78
|
get selectedNode(): GraphNode<N, L>;
|
|
81
|
-
get selectedNodes(): GraphNode<N, L>[];
|
|
82
79
|
get selectedLink(): GraphLink<N, L>;
|
|
83
80
|
constructor(config?: GraphConfigInterface<N, L>);
|
|
84
81
|
setData(data: {
|
|
@@ -97,7 +94,6 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
97
94
|
private _fit;
|
|
98
95
|
private _getTransform;
|
|
99
96
|
private _selectNode;
|
|
100
|
-
private _selectNodes;
|
|
101
97
|
private _selectLink;
|
|
102
98
|
private _resetSelection;
|
|
103
99
|
private _updateSelectedElements;
|
|
@@ -110,15 +106,9 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
110
106
|
private _onLinkMouseOut;
|
|
111
107
|
private _onLinkFlowTimerFrame;
|
|
112
108
|
private _onZoom;
|
|
113
|
-
private _updateNodePosition;
|
|
114
|
-
private _onBrush;
|
|
115
|
-
private _handleDrag;
|
|
116
109
|
private _onDragStarted;
|
|
117
110
|
private _onDragged;
|
|
118
111
|
private _onDragEnded;
|
|
119
|
-
private _dragSelectedNodes;
|
|
120
|
-
private _activateBrush;
|
|
121
|
-
private _clearBrush;
|
|
122
112
|
private _shouldLayoutRecalculate;
|
|
123
113
|
private _getLinkArrowDefId;
|
|
124
114
|
private _addSVGDefs;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { min, max } from 'd3-array';
|
|
3
3
|
import { select, pointer } from 'd3-selection';
|
|
4
|
-
import { brush as brush$1 } from 'd3-brush';
|
|
5
4
|
import { zoom, zoomTransform, zoomIdentity } from 'd3-zoom';
|
|
6
5
|
import { drag } from 'd3-drag';
|
|
7
6
|
import { interval } from 'd3-timer';
|
|
@@ -11,12 +10,12 @@ import { isNumber, clamp, getBoolean, isFunction, shallowDiff } from '../../util
|
|
|
11
10
|
import { smartTransition } from '../../utils/d3.js';
|
|
12
11
|
import { GraphLayoutType, GraphLinkArrowStyle } from './types.js';
|
|
13
12
|
import { GraphDefaultConfig } from './config.js';
|
|
14
|
-
import { background, graphGroup,
|
|
13
|
+
import { background, graphGroup, root } from './style.js';
|
|
15
14
|
import * as style from './modules/node/style.js';
|
|
16
|
-
import { nodes, gNode, gNodeExit,
|
|
15
|
+
import { nodes, gNode, gNodeExit, node, nodeGauge, sideLabelGroup, label, greyedOutNode } from './modules/node/style.js';
|
|
17
16
|
import { links, gLink, gLinkExit, link, greyedOutLink } from './modules/link/style.js';
|
|
18
17
|
import { panels, gPanel, panel, panelSelection, label as label$1, labelText, sideIconGroup, sideIconShape, sideIconSymbol } from './modules/panel/style.js';
|
|
19
|
-
import { createNodes, updateNodes, removeNodes,
|
|
18
|
+
import { createNodes, updateNodes, removeNodes, updateNodeSelectedGreyout, zoomNodesThrottled, zoomNodes } from './modules/node/index.js';
|
|
20
19
|
import { getMaxNodeSize, getX, getY, getNodeSize } from './modules/node/helper.js';
|
|
21
20
|
import { createLinks, updateLinks, removeLinks, updateSelectedLinks, animateLinkFlow, zoomLinksThrottled, zoomLinks } from './modules/link/index.js';
|
|
22
21
|
import { getArrowPath, getDoubleArrowPath } from './modules/link/helper.js';
|
|
@@ -54,28 +53,17 @@ class Graph extends ComponentCore {
|
|
|
54
53
|
this.setConfig(config);
|
|
55
54
|
this._backgroundRect = this.g.append('rect').attr('class', background);
|
|
56
55
|
this._graphGroup = this.g.append('g').attr('class', graphGroup);
|
|
57
|
-
this._brush = this.g.append('g').attr('class', brush);
|
|
58
56
|
this._zoomBehavior = zoom()
|
|
59
57
|
.scaleExtent(this.config.zoomScaleExtent)
|
|
60
|
-
.on('zoom', (e) => this._onZoom(e.transform, e))
|
|
61
|
-
.filter(event => !event.shiftKey);
|
|
62
|
-
this._brushBehavior = brush$1()
|
|
63
|
-
.on('start brush end', this._onBrush.bind(this))
|
|
64
|
-
.filter(event => event.shiftKey)
|
|
65
|
-
.keyModifiers(false);
|
|
58
|
+
.on('zoom', (e) => this._onZoom(e.transform, e));
|
|
66
59
|
this._panelsGroup = this._graphGroup.append('g').attr('class', panels);
|
|
67
60
|
this._linksGroup = this._graphGroup.append('g').attr('class', links);
|
|
68
61
|
this._nodesGroup = this._graphGroup.append('g').attr('class', nodes);
|
|
69
62
|
this._defs = this._graphGroup.append('defs');
|
|
70
63
|
this._getLinkArrowDefId = this._getLinkArrowDefId.bind(this);
|
|
71
64
|
}
|
|
72
|
-
/** @deprecated Use selectedNodes instead */
|
|
73
65
|
get selectedNode() {
|
|
74
|
-
|
|
75
|
-
return (_a = this._selectedNodes) === null || _a === void 0 ? void 0 : _a[0];
|
|
76
|
-
}
|
|
77
|
-
get selectedNodes() {
|
|
78
|
-
return this._selectedNodes;
|
|
66
|
+
return this._selectedNode;
|
|
79
67
|
}
|
|
80
68
|
get selectedLink() {
|
|
81
69
|
return this._selectedLink;
|
|
@@ -94,6 +82,8 @@ class Graph extends ComponentCore {
|
|
|
94
82
|
super.setConfig(config);
|
|
95
83
|
this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate();
|
|
96
84
|
this._shouldFitLayout = this._shouldFitLayout || this._shouldRecalculateLayout;
|
|
85
|
+
if (this._shouldFitLayout)
|
|
86
|
+
this._isAutoFitDisabled = false;
|
|
97
87
|
this._shouldSetPanels = true;
|
|
98
88
|
}
|
|
99
89
|
get bleed() {
|
|
@@ -101,7 +91,7 @@ class Graph extends ComponentCore {
|
|
|
101
91
|
return { top: extraPadding, bottom: extraPadding, left: extraPadding, right: extraPadding };
|
|
102
92
|
}
|
|
103
93
|
_render(customDuration) {
|
|
104
|
-
const { config: {
|
|
94
|
+
const { config: { disableZoom, duration, layoutAutofit }, datamodel } = this;
|
|
105
95
|
if (!datamodel.nodes && !datamodel.links)
|
|
106
96
|
return;
|
|
107
97
|
const animDuration = isNumber(customDuration) ? customDuration : duration;
|
|
@@ -115,31 +105,18 @@ class Graph extends ComponentCore {
|
|
|
115
105
|
this._prevWidth = this._width;
|
|
116
106
|
this._prevHeight = this._height;
|
|
117
107
|
}
|
|
118
|
-
// Handle brush behavior
|
|
119
|
-
if (!disableBrush) {
|
|
120
|
-
this._brushBehavior.extent([[0, 0], [this._width, this._height]]);
|
|
121
|
-
this._brush.call(this._brushBehavior);
|
|
122
|
-
// Activate the brush when the shift key is pressed
|
|
123
|
-
select(window)
|
|
124
|
-
.on('keydown.unovis-graph', e => e.key === 'Shift' && this._activateBrush())
|
|
125
|
-
.on('keyup.unovis-graph', e => e.key === 'Shift' && this._clearBrush());
|
|
126
|
-
this._zoomBehavior.filter(event => !event.shiftKey);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this._brush.on('.brush', null);
|
|
130
|
-
select(window)
|
|
131
|
-
.on('keydown.unovis-graph', null)
|
|
132
|
-
.on('keyup.unovis-graph', null);
|
|
133
|
-
// Clear brush in case it was disabled in an active state
|
|
134
|
-
if (this._brush.classed('active'))
|
|
135
|
-
this._clearBrush();
|
|
136
|
-
}
|
|
137
108
|
// Apply layout and render
|
|
138
109
|
if (this._shouldRecalculateLayout || !this._layoutCalculationPromise) {
|
|
139
110
|
this._layoutCalculationPromise = this._calculateLayout();
|
|
111
|
+
// Call `onLayoutCalculated` after the layout calculation is done and the `this._layoutCalculationPromise`
|
|
112
|
+
// variable is set because the `fitView` function relies on the promise to be initialized
|
|
113
|
+
this._layoutCalculationPromise.then(() => {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
(_b = (_a = this.config).onLayoutCalculated) === null || _b === void 0 ? void 0 : _b.call(_a, datamodel.nodes, datamodel.links);
|
|
116
|
+
});
|
|
140
117
|
}
|
|
141
118
|
this._layoutCalculationPromise.then((isFirstRender) => {
|
|
142
|
-
var _a;
|
|
119
|
+
var _a, _b;
|
|
143
120
|
// If the component has been destroyed while the layout calculation
|
|
144
121
|
// was in progress, we cancel the render
|
|
145
122
|
if (this.isDestroyed())
|
|
@@ -159,10 +136,9 @@ class Graph extends ComponentCore {
|
|
|
159
136
|
this._drawLinks(animDuration);
|
|
160
137
|
// Select Links / Nodes
|
|
161
138
|
this._resetSelection();
|
|
162
|
-
if (this.config.selectedNodeId
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
this._selectNodes(selectedNodes);
|
|
139
|
+
if (this.config.selectedNodeId) {
|
|
140
|
+
const selectedNode = datamodel.nodes.find(node => node.id === this.config.selectedNodeId);
|
|
141
|
+
this._selectNode(selectedNode);
|
|
166
142
|
}
|
|
167
143
|
if (this.config.selectedLinkId) {
|
|
168
144
|
const selectedLink = datamodel.links.find(link => link.id === this.config.selectedLinkId);
|
|
@@ -194,6 +170,8 @@ class Graph extends ComponentCore {
|
|
|
194
170
|
// calculation and they were not set up properly (see the render function of `ComponentCore`)
|
|
195
171
|
this._setUpComponentEventsThrottled();
|
|
196
172
|
this._setCustomAttributesThrottled();
|
|
173
|
+
// On render complete callback
|
|
174
|
+
(_b = (_a = this.config).onRenderComplete) === null || _b === void 0 ? void 0 : _b.call(_a, this.g, datamodel.nodes, datamodel.links, this.config, animDuration, this._scale);
|
|
197
175
|
});
|
|
198
176
|
this._isFirstRender = false;
|
|
199
177
|
}
|
|
@@ -205,21 +183,21 @@ class Graph extends ComponentCore {
|
|
|
205
183
|
.data(nodes, d => String(d._id));
|
|
206
184
|
const nodeGroupsEnter = nodeGroups.enter().append('g')
|
|
207
185
|
.attr('class', gNode)
|
|
208
|
-
.call(createNodes, config, duration);
|
|
186
|
+
.call(createNodes, config, duration, this._scale);
|
|
209
187
|
const nodeGroupsMerged = nodeGroups.merge(nodeGroupsEnter);
|
|
210
188
|
const nodeUpdateSelection = updateNodes(nodeGroupsMerged, config, duration, this._scale);
|
|
211
189
|
this._drawPanels(nodeUpdateSelection, duration);
|
|
212
190
|
const nodesGroupExit = nodeGroups.exit();
|
|
213
191
|
nodesGroupExit
|
|
214
192
|
.classed(gNodeExit, true)
|
|
215
|
-
.call(removeNodes, config, duration);
|
|
193
|
+
.call(removeNodes, config, duration, this._scale);
|
|
216
194
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
217
195
|
const thisRef = this;
|
|
218
196
|
if (!config.disableDrag) {
|
|
219
197
|
const dragBehaviour = drag()
|
|
220
|
-
.on('start
|
|
221
|
-
thisRef.
|
|
222
|
-
|
|
198
|
+
.on('start', function (event, d) { thisRef._onDragStarted(d, event, select(this)); })
|
|
199
|
+
.on('drag', function (event, d) { thisRef._onDragged(d, event, nodeGroupsMerged); })
|
|
200
|
+
.on('end', function (event, d) { thisRef._onDragEnded(d, event, select(this)); });
|
|
223
201
|
nodeGroupsMerged.call(dragBehaviour);
|
|
224
202
|
}
|
|
225
203
|
else {
|
|
@@ -272,10 +250,16 @@ class Graph extends ComponentCore {
|
|
|
272
250
|
panelToUpdate.call(updatePanels, config, duration);
|
|
273
251
|
}
|
|
274
252
|
_calculateLayout() {
|
|
275
|
-
var _a, _b;
|
|
276
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
254
|
const { config, datamodel } = this;
|
|
278
255
|
const firstRender = this._isFirstRender;
|
|
256
|
+
// If the layout type has changed, we need to reset the node positions if they were fixed before
|
|
257
|
+
if (this._currentLayoutType !== config.layoutType) {
|
|
258
|
+
for (const node of datamodel.nodes) {
|
|
259
|
+
delete node._state.fx;
|
|
260
|
+
delete node._state.fy;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
279
263
|
switch (config.layoutType) {
|
|
280
264
|
case GraphLayoutType.Precalculated:
|
|
281
265
|
break;
|
|
@@ -305,8 +289,8 @@ class Graph extends ComponentCore {
|
|
|
305
289
|
// We need to update the panels data right after the layout calculation
|
|
306
290
|
// because we want to have the latest coordinates before calling `onLayoutCalculated`
|
|
307
291
|
this._initPanelsData();
|
|
308
|
-
(_b = (_a = this.config).onLayoutCalculated) === null || _b === void 0 ? void 0 : _b.call(_a, datamodel.nodes, datamodel.links);
|
|
309
292
|
this._shouldRecalculateLayout = false;
|
|
293
|
+
this._currentLayoutType = config.layoutType;
|
|
310
294
|
return firstRender;
|
|
311
295
|
});
|
|
312
296
|
}
|
|
@@ -356,9 +340,21 @@ class Graph extends ComponentCore {
|
|
|
356
340
|
return transform;
|
|
357
341
|
}
|
|
358
342
|
_selectNode(node) {
|
|
359
|
-
const { datamodel: { links } } = this;
|
|
343
|
+
const { datamodel: { nodes, links } } = this;
|
|
360
344
|
if (!node)
|
|
361
345
|
console.warn('Unovis | Graph: Select Node: Not found');
|
|
346
|
+
this._selectedNode = node;
|
|
347
|
+
// Apply grey out
|
|
348
|
+
// Grey out all nodes
|
|
349
|
+
nodes.forEach(n => {
|
|
350
|
+
n._state.selected = false;
|
|
351
|
+
n._state.greyout = true;
|
|
352
|
+
});
|
|
353
|
+
// Grey out all links
|
|
354
|
+
links.forEach(l => {
|
|
355
|
+
l._state.greyout = true;
|
|
356
|
+
l._state.selected = false;
|
|
357
|
+
});
|
|
362
358
|
// Highlight selected
|
|
363
359
|
if (node) {
|
|
364
360
|
node._state.selected = true;
|
|
@@ -374,24 +370,6 @@ class Graph extends ComponentCore {
|
|
|
374
370
|
}
|
|
375
371
|
this._updateSelectedElements();
|
|
376
372
|
}
|
|
377
|
-
_selectNodes(nodes) {
|
|
378
|
-
// Apply grey out
|
|
379
|
-
// Grey out all nodes
|
|
380
|
-
this.datamodel.nodes.forEach(n => {
|
|
381
|
-
n._state.selected = false;
|
|
382
|
-
n._state.greyout = true;
|
|
383
|
-
});
|
|
384
|
-
// Grey out all links
|
|
385
|
-
this.datamodel.links.forEach(l => {
|
|
386
|
-
l._state.greyout = true;
|
|
387
|
-
l._state.selected = false;
|
|
388
|
-
});
|
|
389
|
-
nodes.forEach(n => {
|
|
390
|
-
this._selectedNodes.push(n);
|
|
391
|
-
this._selectNode(n);
|
|
392
|
-
});
|
|
393
|
-
this._updateSelectedElements();
|
|
394
|
-
}
|
|
395
373
|
_selectLink(link) {
|
|
396
374
|
const { datamodel: { nodes, links } } = this;
|
|
397
375
|
if (!link)
|
|
@@ -426,7 +404,7 @@ class Graph extends ComponentCore {
|
|
|
426
404
|
}
|
|
427
405
|
_resetSelection() {
|
|
428
406
|
const { datamodel: { nodes, links } } = this;
|
|
429
|
-
this.
|
|
407
|
+
this._selectedNode = undefined;
|
|
430
408
|
this._selectedLink = undefined;
|
|
431
409
|
// Disable Grayout
|
|
432
410
|
nodes.forEach(n => {
|
|
@@ -444,7 +422,7 @@ class Graph extends ComponentCore {
|
|
|
444
422
|
const linkElements = this._linksGroup.selectAll(`.${gLink}`);
|
|
445
423
|
linkElements.call(updateSelectedLinks, config, this._scale);
|
|
446
424
|
const nodeElements = this._nodesGroup.selectAll(`.${gNode}`);
|
|
447
|
-
nodeElements.call(
|
|
425
|
+
nodeElements.call(updateNodeSelectedGreyout, config);
|
|
448
426
|
// this._drawPanels(nodeElements, 0)
|
|
449
427
|
}
|
|
450
428
|
_onBackgroundClick() {
|
|
@@ -516,17 +494,27 @@ class Graph extends ComponentCore {
|
|
|
516
494
|
this._linksGroup.selectAll(`.${gLink}`)
|
|
517
495
|
.call((nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomLinksThrottled : zoomLinks), config, this._scale, this._getLinkArrowDefId);
|
|
518
496
|
}
|
|
519
|
-
|
|
520
|
-
var _a
|
|
497
|
+
_onDragStarted(d, event, nodeSelection) {
|
|
498
|
+
var _a;
|
|
499
|
+
const { config } = this;
|
|
500
|
+
this._isDragging = true;
|
|
501
|
+
d._state.isDragged = true;
|
|
502
|
+
nodeSelection.call(updateNodes, config, 0, this._scale);
|
|
503
|
+
(_a = config.onNodeDragStart) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
|
|
504
|
+
}
|
|
505
|
+
_onDragged(d, event, allNodesSelection) {
|
|
506
|
+
var _a, _b, _c;
|
|
507
|
+
const { config } = this;
|
|
521
508
|
const transform = zoomTransform(this.g.node());
|
|
522
509
|
const scale = transform.k;
|
|
523
510
|
// Prevent the node from being dragged offscreen or outside its panel
|
|
524
511
|
const panels = (_b = (_a = this._panels) === null || _a === void 0 ? void 0 : _a.filter(p => p.nodes.includes(d._id))) !== null && _b !== void 0 ? _b : [];
|
|
525
|
-
const nodeSizeValue = getNodeSize(d,
|
|
512
|
+
const nodeSizeValue = getNodeSize(d, config.nodeSize, d._index);
|
|
526
513
|
const maxY = min([(this._height - transform.y) / scale, ...panels.map(p => p._y + p._height)]) - nodeSizeValue / 2;
|
|
527
514
|
const maxX = min([(this._width - transform.x) / scale, ...panels.map(p => p._x + p._width)]) - nodeSizeValue / 2;
|
|
528
515
|
const minY = max([-transform.y / scale, ...panels.map(p => p._y)]) + nodeSizeValue / 2;
|
|
529
516
|
const minX = max([-transform.x / scale, ...panels.map(p => p._x)]) + nodeSizeValue / 2;
|
|
517
|
+
let [x, y] = pointer(event, this._graphGroup.node());
|
|
530
518
|
if (y < minY)
|
|
531
519
|
y = minY;
|
|
532
520
|
else if (y > maxY)
|
|
@@ -547,62 +535,6 @@ class Graph extends ComponentCore {
|
|
|
547
535
|
delete d._state.fx;
|
|
548
536
|
if (d._state.fy === d.y)
|
|
549
537
|
delete d._state.fy;
|
|
550
|
-
}
|
|
551
|
-
_onBrush(event) {
|
|
552
|
-
var _a;
|
|
553
|
-
if (!event.selection || !event.sourceEvent)
|
|
554
|
-
return;
|
|
555
|
-
const { config } = this;
|
|
556
|
-
const transform = zoomTransform(this._graphGroup.node());
|
|
557
|
-
const [xMin, yMin] = transform.invert(event.selection[0]);
|
|
558
|
-
const [xMax, yMax] = transform.invert(event.selection[1]);
|
|
559
|
-
// Update brushed nodes
|
|
560
|
-
this._nodesGroup.selectAll(`.${gNode}`)
|
|
561
|
-
.each(n => {
|
|
562
|
-
const x = getX(n);
|
|
563
|
-
const y = getY(n);
|
|
564
|
-
n._state.brushed = x >= xMin && x <= xMax && y >= yMin && y <= yMax;
|
|
565
|
-
})
|
|
566
|
-
.classed(brushed, n => n._state.brushed);
|
|
567
|
-
const brushedNodes = this._nodesGroup.selectAll(`.${brushed}`)
|
|
568
|
-
.call(updateSelectedNodes, config, 0, this._scale);
|
|
569
|
-
this._brush.classed('active', event.type !== 'end');
|
|
570
|
-
(_a = config.onNodeSelectionBrush) === null || _a === void 0 ? void 0 : _a.call(config, brushedNodes.data(), event);
|
|
571
|
-
}
|
|
572
|
-
_handleDrag(d, event, nodeSelection) {
|
|
573
|
-
if (event.sourceEvent.shiftKey && d._state.brushed) {
|
|
574
|
-
this._dragSelectedNodes(event);
|
|
575
|
-
}
|
|
576
|
-
else if (!event.sourceEvent.shiftKey) {
|
|
577
|
-
switch (event.type) {
|
|
578
|
-
case 'start':
|
|
579
|
-
this._onDragStarted(d, event, nodeSelection);
|
|
580
|
-
break;
|
|
581
|
-
case 'drag':
|
|
582
|
-
this._onDragged(d, event);
|
|
583
|
-
break;
|
|
584
|
-
case 'end':
|
|
585
|
-
this._onDragEnded(d, event, nodeSelection);
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
_onDragStarted(d, event, nodeSelection) {
|
|
591
|
-
var _a;
|
|
592
|
-
const { config } = this;
|
|
593
|
-
this._isDragging = true;
|
|
594
|
-
d._state.isDragged = true;
|
|
595
|
-
nodeSelection.call(updateNodes, config, 0, this._scale);
|
|
596
|
-
(_a = config.onNodeDragStart) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
|
|
597
|
-
}
|
|
598
|
-
_onDragged(d, event) {
|
|
599
|
-
var _a;
|
|
600
|
-
const { config } = this;
|
|
601
|
-
const transform = zoomTransform(this.g.node());
|
|
602
|
-
const scale = transform.k;
|
|
603
|
-
// Update node position
|
|
604
|
-
const [x, y] = pointer(event, this._graphGroup.node());
|
|
605
|
-
this._updateNodePosition(d, x, y);
|
|
606
538
|
// Update affected DOM elements
|
|
607
539
|
const nodeSelection = this._nodesGroup.selectAll(`.${gNode}`);
|
|
608
540
|
const nodeToUpdate = nodeSelection.filter((n) => n._id === d._id);
|
|
@@ -617,7 +549,7 @@ class Graph extends ComponentCore {
|
|
|
617
549
|
const linksToAnimate = linksToUpdate.filter(d => d._state.greyout);
|
|
618
550
|
if (linksToAnimate.size())
|
|
619
551
|
animateLinkFlow(linksToAnimate, config, this._scale);
|
|
620
|
-
(
|
|
552
|
+
(_c = config.onNodeDrag) === null || _c === void 0 ? void 0 : _c.call(config, d, event);
|
|
621
553
|
}
|
|
622
554
|
_onDragEnded(d, event, nodeSelection) {
|
|
623
555
|
var _a;
|
|
@@ -627,49 +559,6 @@ class Graph extends ComponentCore {
|
|
|
627
559
|
nodeSelection.call(updateNodes, config, 0, this._scale);
|
|
628
560
|
(_a = config.onNodeDragEnd) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
|
|
629
561
|
}
|
|
630
|
-
_dragSelectedNodes(event) {
|
|
631
|
-
var _a, _b;
|
|
632
|
-
const { config } = this;
|
|
633
|
-
const curr = pointer(event, this._graphGroup.node());
|
|
634
|
-
const selectedNodes = smartTransition(this._nodesGroup.selectAll(`.${brushed}`));
|
|
635
|
-
if (event.type === 'start') {
|
|
636
|
-
this._groupDragInit = curr;
|
|
637
|
-
this._isDragging = true;
|
|
638
|
-
selectedNodes.each(n => {
|
|
639
|
-
n.x = getX(n);
|
|
640
|
-
n.y = getY(n);
|
|
641
|
-
n._state.isDragged = true;
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
else if (event.type === 'drag') {
|
|
645
|
-
const dx = curr[0] - this._groupDragInit[0];
|
|
646
|
-
const dy = curr[1] - this._groupDragInit[1];
|
|
647
|
-
selectedNodes.each(n => this._updateNodePosition(n, n.x + dx, n.y + dy));
|
|
648
|
-
const connectedLinks = smartTransition(this._linksGroup.selectAll(`.${gLink}`)
|
|
649
|
-
.filter(l => { var _a, _b, _c, _d; return ((_b = (_a = l.source) === null || _a === void 0 ? void 0 : _a._state) === null || _b === void 0 ? void 0 : _b.isDragged) || ((_d = (_c = l.target) === null || _c === void 0 ? void 0 : _c._state) === null || _d === void 0 ? void 0 : _d.isDragged); }));
|
|
650
|
-
connectedLinks.call(updateLinks, this.config, 0, this._scale, this._getLinkArrowDefId);
|
|
651
|
-
}
|
|
652
|
-
else {
|
|
653
|
-
this._isDragging = false;
|
|
654
|
-
selectedNodes.each(n => { n._state.isDragged = false; });
|
|
655
|
-
}
|
|
656
|
-
selectedNodes.call(updateNodes, config, 0, this._scale);
|
|
657
|
-
(_b = (_a = this.config).onNodeSelectionDrag) === null || _b === void 0 ? void 0 : _b.call(_a, selectedNodes.data(), event);
|
|
658
|
-
}
|
|
659
|
-
_activateBrush() {
|
|
660
|
-
this._brush.classed('active', true);
|
|
661
|
-
this._nodesGroup.selectAll(`.${gNode}`)
|
|
662
|
-
.classed(brushable, true);
|
|
663
|
-
}
|
|
664
|
-
_clearBrush() {
|
|
665
|
-
var _a;
|
|
666
|
-
this._brush.classed('active', false).call((_a = this._brushBehavior) === null || _a === void 0 ? void 0 : _a.clear);
|
|
667
|
-
this._nodesGroup.selectAll(`.${gNode}`)
|
|
668
|
-
.classed(brushable, false)
|
|
669
|
-
.classed(brushed, false)
|
|
670
|
-
.each(n => { n._state.brushed = false; })
|
|
671
|
-
.call(updateSelectedNodes, this.config, 0, this._scale);
|
|
672
|
-
}
|
|
673
562
|
_shouldLayoutRecalculate() {
|
|
674
563
|
const { prevConfig, config } = this;
|
|
675
564
|
if (prevConfig.layoutType !== config.layoutType)
|
|
@@ -765,6 +654,7 @@ class Graph extends ComponentCore {
|
|
|
765
654
|
}
|
|
766
655
|
Graph.selectors = {
|
|
767
656
|
root: root,
|
|
657
|
+
graphGroup: graphGroup,
|
|
768
658
|
background: background,
|
|
769
659
|
node: gNode,
|
|
770
660
|
nodeShape: node,
|