@unovis/ts 1.3.6-beta.1 → 1.3.6-beta.2

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.
Files changed (40) hide show
  1. package/components/graph/config.d.ts +22 -15
  2. package/components/graph/config.js +4 -2
  3. package/components/graph/config.js.map +1 -1
  4. package/components/graph/index.d.ts +7 -2
  5. package/components/graph/index.js +114 -110
  6. package/components/graph/index.js.map +1 -1
  7. package/components/graph/modules/layout.js +30 -19
  8. package/components/graph/modules/layout.js.map +1 -1
  9. package/components/graph/modules/link/helper.d.ts +4 -6
  10. package/components/graph/modules/link/helper.js +15 -25
  11. package/components/graph/modules/link/helper.js.map +1 -1
  12. package/components/graph/modules/link/index.d.ts +3 -3
  13. package/components/graph/modules/link/index.js +111 -89
  14. package/components/graph/modules/link/index.js.map +1 -1
  15. package/components/graph/modules/link/style.d.ts +5 -5
  16. package/components/graph/modules/link/style.js +26 -22
  17. package/components/graph/modules/link/style.js.map +1 -1
  18. package/components/graph/modules/node/helper.d.ts +1 -0
  19. package/components/graph/modules/node/helper.js +4 -1
  20. package/components/graph/modules/node/helper.js.map +1 -1
  21. package/components/graph/modules/node/index.js +28 -11
  22. package/components/graph/modules/node/index.js.map +1 -1
  23. package/components/graph/modules/node/style.d.ts +1 -1
  24. package/components/graph/modules/node/style.js +13 -6
  25. package/components/graph/modules/node/style.js.map +1 -1
  26. package/components/graph/modules/shape.d.ts +0 -2
  27. package/components/graph/modules/shape.js +7 -9
  28. package/components/graph/modules/shape.js.map +1 -1
  29. package/components/graph/types.d.ts +63 -5
  30. package/components/graph/types.js +1 -0
  31. package/components/graph/types.js.map +1 -1
  32. package/core/component/index.d.ts +3 -3
  33. package/core/component/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/utils/data.js +1 -1
  36. package/utils/data.js.map +1 -1
  37. package/utils/svg.d.ts +3 -0
  38. package/utils/svg.js +61 -0
  39. package/utils/svg.js.map +1 -0
  40. package/utils/text.js.map +1 -1
@@ -1,8 +1,10 @@
1
+ import { D3DragEvent } from 'd3-drag';
2
+ import { D3ZoomEvent } from 'd3-zoom';
1
3
  import { ComponentConfigInterface } from "../../core/component/config";
2
4
  import { TrimMode } from "../../types/text";
3
5
  import { GraphInputLink, GraphInputNode } from "../../types/graph";
4
6
  import { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from "../../types/accessor";
5
- import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape } from './types';
7
+ import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape, GraphDagreLayoutSetting, GraphNode, GraphLink } from './types';
6
8
  export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {
7
9
  /** Zoom level constraints. Default: [0.35, 1.25] */
8
10
  zoomScaleExtent?: [number, number];
@@ -12,8 +14,6 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
12
14
  disableDrag?: boolean;
13
15
  /** Interval to re-render the graph when zooming. Default: `100` */
14
16
  zoomThrottledUpdateNodeThreshold?: number;
15
- /** Zoom event callback. Default: `undefined` */
16
- onZoom?: (zoomScale: number, zoomScaleExtent: [number, number]) => void;
17
17
  /** Type of the graph layout. Default: `GraphLayoutType.Force` */
18
18
  layoutType?: GraphLayoutType | string;
19
19
  /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */
@@ -56,20 +56,11 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
56
56
  * Default: `undefined` */
57
57
  layoutParallelSortConnectionsByGroup?: string;
58
58
  /** Force Layout settings, see the `d3-force` package for more details */
59
- forceLayoutSettings?: GraphForceLayoutSettings;
59
+ forceLayoutSettings?: GraphForceLayoutSettings<N, L>;
60
60
  /** Darge Layout settings, see the `dagrejs` package
61
61
  * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout
62
62
  */
63
- dagreLayoutSettings?: {
64
- /** Direction for rank node. `TB`, `BT`, `LR`, or `RL`. Default: `BT` */
65
- rankdir: string;
66
- /** Type of algorithm to assigns a rank to each node in the input graph.
67
- * `network-simplex`, `tight-tree` or `longest-path`.
68
- * Default: `longest-path` */
69
- ranker: string;
70
- /** Other configurable Dagre settings. https://github.com/dagrejs/dagre/wiki */
71
- [key: string]: any;
72
- };
63
+ dagreLayoutSettings?: GraphDagreLayoutSetting;
73
64
  /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.
74
65
  * If you want to specify custom layout option for each node group, you can provide an accessor function that
75
66
  * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing
@@ -87,7 +78,7 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
87
78
  /** Link band width accessor function or constant value. Default: `0` */
88
79
  linkBandWidth?: NumericAccessor<L>;
89
80
  /** Link arrow accessor function or constant value. Default: `undefined` */
90
- linkArrow?: GenericAccessor<GraphLinkArrowStyle, L> | undefined;
81
+ linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;
91
82
  /** Link stroke color accessor function or constant value. Default: `undefined` */
92
83
  linkStroke?: ColorAccessor<L>;
93
84
  /** Link disabled state accessor function or constant value. Default: `false` */
@@ -104,6 +95,12 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
104
95
  linkLabelShiftFromCenter?: BooleanAccessor<L>;
105
96
  /** Spacing between neighboring links. Default: `8` */
106
97
  linkNeighborSpacing?: number;
98
+ /** Curvature of the link. Recommended value range: [0:1.5].
99
+ * `0` - straight line,
100
+ * `1` - nice curvature,
101
+ * `1.5` - very curve.
102
+ * Default: `0` */
103
+ linkCurvature?: NumericAccessor<L>;
107
104
  /** Set selected link by its unique id. Default: `undefined` */
108
105
  selectedLinkId?: number | string;
109
106
  /** Node size accessor function or constant value. Default: `30` */
@@ -162,5 +159,15 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
162
159
  selectedNodeId?: number | string;
163
160
  /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */
164
161
  panels?: GraphPanelConfig[] | undefined;
162
+ /** Graph node drag start callback function. Default: `undefined` */
163
+ onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;
164
+ /** Graph node drag callback function. Default: `undefined` */
165
+ onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;
166
+ /** Graph node drag end callback function. Default: `undefined` */
167
+ onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;
168
+ /** Zoom event callback. Default: `undefined` */
169
+ onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined) => void;
170
+ /** Callback function to be called when the graph layout is calculated. Default: `undefined` */
171
+ onLayoutCalculated?: (n: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;
165
172
  }
166
173
  export declare const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink>;
@@ -3,16 +3,18 @@ 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, zoomThrottledUpdateNodeThreshold: 100, onZoom: undefined, 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: {
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,
10
10
  forceXStrength: 0.15,
11
11
  forceYStrength: 0.25,
12
+ numIterations: undefined,
13
+ fixNodePositionAfterSimulation: false,
12
14
  }, dagreLayoutSettings: {
13
15
  rankdir: 'BT',
14
16
  ranker: 'longest-path',
15
- }, 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, 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 });
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 });
16
18
 
17
19
  export { GraphDefaultConfig };
18
20
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["// 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} 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 /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number]) => void;\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\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?: {\n /** Direction for rank node. `TB`, `BT`, `LR`, or `RL`. Default: `BT` */\n rankdir: string;\n /** Type of algorithm to assigns a rank to each node in the input graph.\n * `network-simplex`, `tight-tree` or `longest-path`.\n * Default: `longest-path` */\n ranker: string;\n /** Other configurable Dagre settings. https://github.com/dagrejs/dagre/wiki */\n [key: string]: any;\n };\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, 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 /** 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 /** 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\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 onZoom: undefined,\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 },\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 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"],"names":[],"mappings":";;;;AAAA;MAuMa,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,WAAW,EAAE,KAAK,EAClB,gCAAgC,EAAE,GAAG,EACrC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,EAC3B,uBAAuB,EAAE,KAAK,EAE9B,gBAAgB,EAAE,EAAE,EACpB,6BAA6B,EAAE,CAAC,EAChC,4BAA4B,EAAE,CAAC,EAC/B,0BAA0B,EAAE,SAAS,EACrC,oCAAoC,EAAE,SAAS,EAC/C,eAAe,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EAC9E,0BAA0B,EAAE,CAAC,CAAiB,KAAc,CAA0B,CAAC,QAAQ,EAE/F,mBAAmB,EAAE;AACnB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,CAAC,GAAG;AACZ,QAAA,cAAc,EAAE,IAAI;AACpB,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,EAED,mBAAmB,EAAE;AACnB,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,MAAM,EAAE,cAAc;KACvB,EAED,iBAAiB,EAAE,SAAS,EAC5B,mBAAmB,EAAE,SAAS,EAE9B,oBAAoB,EAAE,KAAK,EAC3B,oBAAoB,EAAE,CAAC,EACvB,SAAS,EAAE,CAAC,EACZ,SAAS,EAAE,cAAc,CAAC,KAAK,EAC/B,aAAa,EAAE,CAAC,EAChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,KAAK,EACf,SAAS,EAAE,SAAS,EACpB,wBAAwB,EAAE,IAAI,EAC9B,mBAAmB,EAAE,CAAC,EACtB,YAAY,EAAE,KAAK,EACnB,cAAc,EAAE,SAAS,EACzB,qBAAqB,EAAE,IAAI,EAE3B,QAAQ,EAAE,EAAE,EACZ,eAAe,EAAE,CAAC,EAClB,SAAS,EAAE,cAAc,CAAC,MAAM,EAChC,cAAc,EAAE,CAAC,EACjB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EACxE,aAAa,EAAE,IAAI,EACnB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAClC,YAAY,EAAE,EAAE,EAChB,gBAAgB,EAAE,IAAI,EACtB,sBAAsB,EAAE,EAAE,EAC1B,oBAAoB,EAAE,QAAQ,CAAC,MAAM,EACrC,cAAc,EAAE,SAAS,EACzB,cAAc,EAAE,SAAS,EACzB,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,aAAa,EAAE,SAAS,EACxB,UAAU,EAAE,CAAC,CAAiB,KAAc,CAAwB,CAAC,MAAM,EAC3E,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,IAAI,EACpB,gBAAgB,EAAE,SAAS,EAC3B,aAAa,EAAE,IAAI,EACnB,QAAQ,EAAE,SAAS,EAEnB,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,SAAS,EAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { 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\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 /** 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}\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}\n"],"names":[],"mappings":";;;;AAGA;AAiNa,MAAA,kBAAkB,mCAC1B,sBAAsB,CAAA,EAAA,EACzB,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,WAAW,EAAE,KAAK,EAClB,gCAAgC,EAAE,GAAG,EACrC,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,EAC3B,uBAAuB,EAAE,KAAK,EAE9B,gBAAgB,EAAE,EAAE,EACpB,6BAA6B,EAAE,CAAC,EAChC,4BAA4B,EAAE,CAAC,EAC/B,0BAA0B,EAAE,SAAS,EACrC,oCAAoC,EAAE,SAAS,EAC/C,eAAe,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EAC9E,0BAA0B,EAAE,CAAC,CAAiB,KAAc,CAA0B,CAAC,QAAQ,EAE/F,mBAAmB,EAAE;AACnB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,CAAC,GAAG;AACZ,QAAA,cAAc,EAAE,IAAI;AACpB,QAAA,cAAc,EAAE,IAAI;AACpB,QAAA,aAAa,EAAE,SAAS;AACxB,QAAA,8BAA8B,EAAE,KAAK;AACtC,KAAA,EAED,mBAAmB,EAAE;AACnB,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,MAAM,EAAE,cAAc;KACvB,EAED,iBAAiB,EAAE,SAAS,EAC5B,mBAAmB,EAAE,SAAS,EAE9B,oBAAoB,EAAE,KAAK,EAC3B,oBAAoB,EAAE,CAAC,EACvB,SAAS,EAAE,CAAC,EACZ,SAAS,EAAE,cAAc,CAAC,KAAK,EAC/B,aAAa,EAAE,CAAC,EAChB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,KAAK,EACf,SAAS,EAAE,SAAS,EACpB,wBAAwB,EAAE,IAAI,EAC9B,mBAAmB,EAAE,CAAC,EACtB,YAAY,EAAE,KAAK,EACnB,aAAa,EAAE,CAAC,EAChB,cAAc,EAAE,SAAS,EACzB,qBAAqB,EAAE,IAAI,EAE3B,QAAQ,EAAE,EAAE,EACZ,eAAe,EAAE,CAAC,EAClB,SAAS,EAAE,cAAc,CAAC,MAAM,EAChC,cAAc,EAAE,CAAC,EACjB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EACxE,aAAa,EAAE,IAAI,EACnB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAClC,YAAY,EAAE,EAAE,EAChB,gBAAgB,EAAE,IAAI,EACtB,sBAAsB,EAAE,EAAE,EAC1B,oBAAoB,EAAE,QAAQ,CAAC,MAAM,EACrC,cAAc,EAAE,SAAS,EACzB,cAAc,EAAE,SAAS,EACzB,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,aAAa,EAAE,SAAS,EACxB,UAAU,EAAE,CAAC,CAAiB,KAAc,CAAwB,CAAC,MAAM,EAC3E,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,IAAI,EACpB,gBAAgB,EAAE,SAAS,EAC3B,aAAa,EAAE,IAAI,EACnB,QAAQ,EAAE,SAAS,EAEnB,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,SAAS,EAEjB,eAAe,EAAE,SAAS,EAC1B,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE,SAAS,EACjB,kBAAkB,EAAE,SAAS,EAAA;;;;"}
@@ -18,8 +18,10 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
18
18
  nodeGauge: string;
19
19
  nodeSideLabel: string;
20
20
  nodeLabel: string;
21
+ dimmedNode: string;
21
22
  link: string;
22
23
  linkLine: string;
24
+ dimmedLink: string;
23
25
  panel: string;
24
26
  panelRect: string;
25
27
  panelSelection: string;
@@ -45,6 +47,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
45
47
  private _prevWidth;
46
48
  private _prevHeight;
47
49
  private _shouldRecalculateLayout;
50
+ private _layoutCalculationPromise;
48
51
  private _shouldFitLayout;
49
52
  private _shouldSetPanels;
50
53
  private _panels;
@@ -85,6 +88,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
85
88
  private _drawPanels;
86
89
  private _updatePanels;
87
90
  private _calculateLayout;
91
+ private _initPanelsData;
88
92
  private _fit;
89
93
  private _getTransform;
90
94
  private _selectNode;
@@ -104,12 +108,13 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
104
108
  private _onDragged;
105
109
  private _onDragEnded;
106
110
  private _shouldLayoutRecalculate;
107
- private _getMarkerId;
111
+ private _getLinkArrowDefId;
108
112
  private _addSVGDefs;
109
113
  zoomIn(increment?: number): void;
110
114
  zoomOut(increment?: number): void;
111
115
  setZoom(zoomLevel: number): void;
112
- fitView(): void;
116
+ getZoom(): number;
117
+ fitView(duration?: number): void;
113
118
  /** Enable automatic fitting to container if it was disabled due to previous zoom / pan interactions */
114
119
  resetAutofitState(): void;
115
120
  /** Get current coordinates of the nodes as an array of { id: string; x: number; y: number } objects */
@@ -6,22 +6,21 @@ import { drag } from 'd3-drag';
6
6
  import { interval } from 'd3-timer';
7
7
  import { ComponentCore } from '../../core/component/index.js';
8
8
  import { GraphDataModel } from '../../data-models/graph.js';
9
- import { isNumber, clamp, getBoolean, isFunction, shallowDiff, unique, clean } from '../../utils/data.js';
10
- import { stringToHtmlId } from '../../utils/misc.js';
9
+ import { isNumber, clamp, getBoolean, isFunction, shallowDiff } from '../../utils/data.js';
11
10
  import { smartTransition } from '../../utils/d3.js';
12
11
  import { GraphLayoutType, GraphLinkArrowStyle } from './types.js';
13
12
  import { GraphDefaultConfig } from './config.js';
14
13
  import { background, graphGroup, root } from './style.js';
15
14
  import * as style from './modules/node/style.js';
16
- import { nodes, gNode, gNodeExit, node, nodeGauge, sideLabelGroup, label } from './modules/node/style.js';
17
- import { links, gLink, gLinkExit, link } from './modules/link/style.js';
15
+ import { nodes, gNode, gNodeExit, node, nodeGauge, sideLabelGroup, label, greyedOutNode } from './modules/node/style.js';
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
18
  import { createNodes, updateNodes, removeNodes, updateSelectedNodes, 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
- import { getLinkColor, getLinkArrow, LINK_MARKER_WIDTH, LINK_MARKER_HEIGHT, getDoubleArrowPath, getArrowPath } from './modules/link/helper.js';
21
+ import { getArrowPath, getDoubleArrowPath } from './modules/link/helper.js';
23
22
  import { removePanels, createPanels, updatePanels } from './modules/panel/index.js';
24
- import { initPanels, setPanelForNodes, updatePanelNumNodes, updatePanelBBoxSize } from './modules/panel/helper.js';
23
+ import { updatePanelNumNodes, updatePanelBBoxSize, initPanels, setPanelForNodes } from './modules/panel/helper.js';
25
24
  import { applyLayoutCircular, applyELKLayout, applyLayoutConcentric, applyLayoutForce, applyLayoutDagre, applyLayoutParallel } from './modules/layout.js';
26
25
 
27
26
  class Graph extends ComponentCore {
@@ -61,7 +60,7 @@ class Graph extends ComponentCore {
61
60
  this._linksGroup = this._graphGroup.append('g').attr('class', links);
62
61
  this._nodesGroup = this._graphGroup.append('g').attr('class', nodes);
63
62
  this._defs = this._graphGroup.append('defs');
64
- this._getMarkerId = this._getMarkerId.bind(this);
63
+ this._getLinkArrowDefId = this._getLinkArrowDefId.bind(this);
65
64
  }
66
65
  get selectedNode() {
67
66
  return this._selectedNode;
@@ -80,9 +79,9 @@ class Graph extends ComponentCore {
80
79
  this._addSVGDefs();
81
80
  }
82
81
  setConfig(config) {
83
- this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate(config);
84
- this._shouldFitLayout = this._shouldFitLayout || this._shouldRecalculateLayout;
85
82
  super.setConfig(config);
83
+ this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate();
84
+ this._shouldFitLayout = this._shouldFitLayout || this._shouldRecalculateLayout;
86
85
  this._shouldSetPanels = true;
87
86
  }
88
87
  get bleed() {
@@ -90,7 +89,7 @@ class Graph extends ComponentCore {
90
89
  return { top: extraPadding, bottom: extraPadding, left: extraPadding, right: extraPadding };
91
90
  }
92
91
  _render(customDuration) {
93
- const { config: { disableZoom, duration, layoutAutofit, panels }, datamodel } = this;
92
+ const { config: { disableZoom, duration, layoutAutofit }, datamodel } = this;
94
93
  if (!datamodel.nodes && !datamodel.links)
95
94
  return;
96
95
  const animDuration = isNumber(customDuration) ? customDuration : duration;
@@ -105,18 +104,16 @@ class Graph extends ComponentCore {
105
104
  this._prevHeight = this._height;
106
105
  }
107
106
  // Apply layout and render
108
- this._calculateLayout().then((isFirstRender) => {
107
+ if (this._shouldRecalculateLayout || !this._layoutCalculationPromise) {
108
+ this._layoutCalculationPromise = this._calculateLayout();
109
+ }
110
+ this._layoutCalculationPromise.then((isFirstRender) => {
109
111
  // If the component has been destroyed while the layout calculation
110
112
  // was in progress, we cancel the render
111
113
  if (this.isDestroyed())
112
114
  return;
113
- if (this._shouldSetPanels) {
114
- smartTransition(this._panelsGroup, duration / 2)
115
- .style('opacity', (panels === null || panels === void 0 ? void 0 : panels.length) ? 1 : 0);
116
- this._panels = initPanels(panels);
117
- setPanelForNodes(this._panels, datamodel.nodes, this.config);
118
- this._shouldSetPanels = false;
119
- }
115
+ this._initPanelsData();
116
+ // Fit the view
120
117
  if (isFirstRender) {
121
118
  this._fit();
122
119
  this._shouldFitLayout = false;
@@ -205,14 +202,17 @@ class Graph extends ComponentCore {
205
202
  .attr('class', gLink)
206
203
  .call(createLinks, config, duration);
207
204
  const linkGroupsMerged = linkGroups.merge(linkGroupsEnter);
208
- linkGroupsMerged.call(updateLinks, config, duration, this._scale, this._getMarkerId);
205
+ linkGroupsMerged.call(updateLinks, config, duration, this._scale, this._getLinkArrowDefId);
209
206
  const linkGroupsExit = linkGroups.exit();
210
207
  linkGroupsExit
211
208
  .attr('class', gLinkExit)
212
209
  .call(removeLinks, config, duration);
213
210
  }
214
211
  _drawPanels(nodeUpdateSelection, duration) {
212
+ var _a;
215
213
  const { config } = this;
214
+ smartTransition(this._panelsGroup, duration / 2)
215
+ .style('opacity', ((_a = config.panels) === null || _a === void 0 ? void 0 : _a.length) ? 1 : 0);
216
216
  if (!this._panels)
217
217
  return;
218
218
  const selection = (nodeUpdateSelection.duration)
@@ -239,51 +239,58 @@ class Graph extends ComponentCore {
239
239
  panelToUpdate.call(updatePanels, config, duration);
240
240
  }
241
241
  _calculateLayout() {
242
+ var _a, _b;
242
243
  return __awaiter(this, void 0, void 0, function* () {
243
244
  const { config, datamodel } = this;
244
245
  const firstRender = this._isFirstRender;
245
- if (this._shouldRecalculateLayout) {
246
- switch (config.layoutType) {
247
- case GraphLayoutType.Parallel:
248
- applyLayoutParallel(datamodel, config, this._width, this._height);
249
- break;
250
- case GraphLayoutType.ParallelHorizontal:
251
- applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal');
252
- break;
253
- case GraphLayoutType.Dagre:
254
- yield applyLayoutDagre(datamodel, config, this._width);
255
- break;
256
- case GraphLayoutType.Force:
257
- yield applyLayoutForce(datamodel, config, this._width);
258
- break;
259
- case GraphLayoutType.Concentric:
260
- applyLayoutConcentric(datamodel, config, this._width, this._height);
261
- break;
262
- case GraphLayoutType.Elk:
263
- yield applyELKLayout(datamodel, config, this._width);
264
- break;
265
- case GraphLayoutType.Circular:
266
- default:
267
- applyLayoutCircular(datamodel, config, this._width, this._height);
268
- break;
269
- }
270
- this._shouldRecalculateLayout = false;
246
+ switch (config.layoutType) {
247
+ case GraphLayoutType.Precalculated:
248
+ break;
249
+ case GraphLayoutType.Parallel:
250
+ applyLayoutParallel(datamodel, config, this._width, this._height);
251
+ break;
252
+ case GraphLayoutType.ParallelHorizontal:
253
+ applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal');
254
+ break;
255
+ case GraphLayoutType.Dagre:
256
+ yield applyLayoutDagre(datamodel, config, this._width);
257
+ break;
258
+ case GraphLayoutType.Force:
259
+ yield applyLayoutForce(datamodel, config, this._width);
260
+ break;
261
+ case GraphLayoutType.Concentric:
262
+ applyLayoutConcentric(datamodel, config, this._width, this._height);
263
+ break;
264
+ case GraphLayoutType.Elk:
265
+ yield applyELKLayout(datamodel, config, this._width);
266
+ break;
267
+ case GraphLayoutType.Circular:
268
+ default:
269
+ applyLayoutCircular(datamodel, config, this._width, this._height);
270
+ break;
271
271
  }
272
+ // We need to update the panels data right after the layout calculation
273
+ // because we want to have the latest coordinates before calling `onLayoutCalculated`
274
+ this._initPanelsData();
275
+ (_b = (_a = this.config).onLayoutCalculated) === null || _b === void 0 ? void 0 : _b.call(_a, datamodel.nodes, datamodel.links);
276
+ this._shouldRecalculateLayout = false;
272
277
  return firstRender;
273
278
  });
274
279
  }
280
+ _initPanelsData() {
281
+ const { config, datamodel } = this;
282
+ if (this._shouldSetPanels) {
283
+ this._panels = initPanels(config.panels);
284
+ setPanelForNodes(this._panels, datamodel.nodes, this.config);
285
+ this._shouldSetPanels = false;
286
+ }
287
+ }
275
288
  _fit(duration = 0) {
276
- var _a;
277
289
  const { datamodel: { nodes } } = this;
278
- if ((nodes === null || nodes === void 0 ? void 0 : nodes.length) && ((_a = this.g) === null || _a === void 0 ? void 0 : _a.size())) {
279
- const transform = this._getTransform(nodes);
280
- smartTransition(this.g, duration)
281
- .call(this._zoomBehavior.transform, transform);
282
- this._onZoom(transform);
283
- }
284
- else {
285
- console.warn('Unovis | Graph: Node data is not defined. Check if the component has been initialized.');
286
- }
290
+ const transform = this._getTransform(nodes);
291
+ smartTransition(this.g, duration)
292
+ .call(this._zoomBehavior.transform, transform);
293
+ this._onZoom(transform);
287
294
  }
288
295
  _getTransform(nodes) {
289
296
  const { nodeSize, zoomScaleExtent } = this.config;
@@ -292,13 +299,17 @@ class Graph extends ComponentCore {
292
299
  const w = this._width;
293
300
  const h = this._height;
294
301
  const xExtent = [
295
- min(nodes, d => { var _a; return getX(d) - maxNodeSize / 2 - (max((_a = d._panels) === null || _a === void 0 ? void 0 : _a.map(p => p._padding.left)) || 0); }),
296
- max(nodes, d => { var _a; return getX(d) + maxNodeSize / 2 + (max((_a = d._panels) === null || _a === void 0 ? void 0 : _a.map(p => p._padding.right)) || 0); }),
302
+ min(nodes, d => getX(d) - maxNodeSize / 2 - (max((d._panels || []).map(p => p._padding.left)) || 0)),
303
+ max(nodes, d => getX(d) + maxNodeSize / 2 + (max((d._panels || []).map(p => p._padding.right)) || 0)),
297
304
  ];
298
305
  const yExtent = [
299
- min(nodes, d => { var _a; return getY(d) - maxNodeSize / 2 - (max((_a = d._panels) === null || _a === void 0 ? void 0 : _a.map(p => p._padding.top)) || 0); }),
300
- max(nodes, d => { var _a; return getY(d) + maxNodeSize / 2 + (max((_a = d._panels) === null || _a === void 0 ? void 0 : _a.map(p => p._padding.bottom)) || 0); }),
306
+ min(nodes, d => getY(d) - maxNodeSize / 2 - (max((d._panels || []).map(p => p._padding.top)) || 0)),
307
+ max(nodes, d => getY(d) + maxNodeSize / 2 + (max((d._panels || []).map(p => p._padding.bottom)) || 0)),
301
308
  ];
309
+ if (xExtent.some(item => item === undefined) || yExtent.some(item => item === undefined)) {
310
+ console.warn('Unovis | Graph: Some of the node coordinates are undefined. This can happen if you try to fit the graph before the layout has been calculated.');
311
+ return zoomIdentity;
312
+ }
302
313
  const xScale = w / (xExtent[1] - xExtent[0] + left + right);
303
314
  const yScale = h / (yExtent[1] - yExtent[0] + top + bottom);
304
315
  const clampedScale = clamp(min([xScale, yScale]), zoomScaleExtent[0], zoomScaleExtent[1]);
@@ -441,7 +452,8 @@ class Graph extends ComponentCore {
441
452
  this._scale = transform.k;
442
453
  this._graphGroup.attr('transform', transform.toString());
443
454
  if (isFunction(config.onZoom))
444
- config.onZoom(this._scale, config.zoomScaleExtent);
455
+ config.onZoom(this._scale, config.zoomScaleExtent, event);
456
+ // console.warn('Unovis | Graph: Zoom: ', transform)
445
457
  if (!this._initialTransform)
446
458
  this._initialTransform = transform;
447
459
  // If the event was triggered by a mouse interaction (pan or zoom) we don't
@@ -451,7 +463,9 @@ class Graph extends ComponentCore {
451
463
  const propVal = transform[prop];
452
464
  const initialPropVal = this._initialTransform[prop];
453
465
  const dVal = Math.abs(propVal - initialPropVal);
454
- return prop === 'k' ? 2 * dVal : dVal / 50;
466
+ const scaledDVal = prop === 'k' ? 20 * dVal : dVal / 15;
467
+ acc += scaledDVal;
468
+ return acc;
455
469
  }, 0);
456
470
  if (diff > config.layoutAutofitTolerance)
457
471
  this._isAutoFitDisabled = true;
@@ -461,16 +475,18 @@ class Graph extends ComponentCore {
461
475
  this._nodesGroup.selectAll(`.${gNode}`)
462
476
  .call((nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomNodesThrottled : zoomNodes), config, this._scale);
463
477
  this._linksGroup.selectAll(`.${gLink}`)
464
- .call((nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomLinksThrottled : zoomLinks), config, this._scale, this._getMarkerId);
478
+ .call((nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomLinksThrottled : zoomLinks), config, this._scale, this._getLinkArrowDefId);
465
479
  }
466
480
  _onDragStarted(d, event, nodeSelection) {
481
+ var _a;
467
482
  const { config } = this;
468
483
  this._isDragging = true;
469
484
  d._state.isDragged = true;
470
485
  nodeSelection.call(updateNodes, config, 0, this._scale);
486
+ (_a = config.onNodeDragStart) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
471
487
  }
472
488
  _onDragged(d, event, allNodesSelection) {
473
- var _a, _b;
489
+ var _a, _b, _c;
474
490
  const { config } = this;
475
491
  const transform = zoomTransform(this.g.node());
476
492
  const scale = transform.k;
@@ -512,79 +528,60 @@ class Graph extends ComponentCore {
512
528
  const target = l.target;
513
529
  return source._id === d._id || target._id === d._id;
514
530
  });
515
- linksToUpdate.call(updateLinks, config, 0, scale, this._getMarkerId);
531
+ linksToUpdate.call(updateLinks, config, 0, scale, this._getLinkArrowDefId);
516
532
  const linksToAnimate = linksToUpdate.filter(d => d._state.greyout);
517
533
  if (linksToAnimate.size())
518
534
  animateLinkFlow(linksToAnimate, config, this._scale);
535
+ (_c = config.onNodeDrag) === null || _c === void 0 ? void 0 : _c.call(config, d, event);
519
536
  }
520
537
  _onDragEnded(d, event, nodeSelection) {
538
+ var _a;
521
539
  const { config } = this;
522
540
  this._isDragging = false;
523
541
  d._state.isDragged = false;
524
542
  nodeSelection.call(updateNodes, config, 0, this._scale);
543
+ (_a = config.onNodeDragEnd) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
525
544
  }
526
- _shouldLayoutRecalculate(nextConfig) {
527
- const { config } = this;
528
- if (config.layoutType !== nextConfig.layoutType)
545
+ _shouldLayoutRecalculate() {
546
+ const { prevConfig, config } = this;
547
+ if (prevConfig.layoutType !== config.layoutType)
529
548
  return true;
530
- if (config.layoutNonConnectedAside !== nextConfig.layoutNonConnectedAside)
549
+ if (prevConfig.layoutNonConnectedAside !== config.layoutNonConnectedAside)
531
550
  return true;
532
- if (config.layoutType === GraphLayoutType.Force) {
533
- const forceSettingsDiff = shallowDiff(config.forceLayoutSettings, nextConfig.forceLayoutSettings);
551
+ if (prevConfig.layoutType === GraphLayoutType.Force) {
552
+ const forceSettingsDiff = shallowDiff(prevConfig.forceLayoutSettings, config.forceLayoutSettings);
534
553
  if (Object.keys(forceSettingsDiff).length)
535
554
  return true;
536
555
  }
537
- if (config.layoutType === GraphLayoutType.Dagre) {
538
- const dagreSettingsDiff = shallowDiff(config.dagreLayoutSettings, nextConfig.dagreLayoutSettings);
556
+ if (prevConfig.layoutType === GraphLayoutType.Dagre) {
557
+ const dagreSettingsDiff = shallowDiff(prevConfig.dagreLayoutSettings, config.dagreLayoutSettings);
539
558
  if (Object.keys(dagreSettingsDiff).length)
540
559
  return true;
541
560
  }
542
- if (config.layoutType === GraphLayoutType.Parallel ||
543
- config.layoutType === GraphLayoutType.ParallelHorizontal ||
544
- config.layoutType === GraphLayoutType.Concentric) {
545
- if (config.layoutGroupOrder !== nextConfig.layoutGroupOrder)
561
+ if (prevConfig.layoutType === GraphLayoutType.Parallel ||
562
+ prevConfig.layoutType === GraphLayoutType.ParallelHorizontal ||
563
+ prevConfig.layoutType === GraphLayoutType.Concentric) {
564
+ if (prevConfig.layoutGroupOrder !== config.layoutGroupOrder)
546
565
  return true;
547
- if (config.layoutParallelNodesPerColumn !== nextConfig.layoutParallelNodesPerColumn)
566
+ if (prevConfig.layoutParallelNodesPerColumn !== config.layoutParallelNodesPerColumn)
548
567
  return true;
549
- if (config.layoutParallelSortConnectionsByGroup !== nextConfig.layoutParallelSortConnectionsByGroup)
568
+ if (prevConfig.layoutParallelSortConnectionsByGroup !== config.layoutParallelSortConnectionsByGroup)
550
569
  return true;
551
570
  }
552
571
  return false;
553
572
  }
554
- _getMarkerId(d, color, arrow) {
555
- const { config } = this;
556
- const c = color !== null && color !== void 0 ? color : getLinkColor(d, config);
557
- const a = arrow !== null && arrow !== void 0 ? arrow : getLinkArrow(d, this._scale, config);
558
- return a && c ? `${this.uid}-${stringToHtmlId(c)}-${a}` : null;
573
+ _getLinkArrowDefId(arrow) {
574
+ return arrow ? `${this.uid}-${arrow}` : null;
559
575
  }
560
576
  _addSVGDefs() {
561
- const { datamodel: { links } } = this;
562
577
  // Clean up old defs
563
578
  this._defs.selectAll('*').remove();
564
- // Get all variations of link colors to create markers
565
- const linkColors = unique(clean(links.map(d => getLinkColor(d, this.config))));
566
- this._defs.selectAll('marker')
567
- .data([
568
- ...linkColors.map(d => ({ color: d, arrow: GraphLinkArrowStyle.Single })),
569
- ...linkColors.map(d => ({ color: d, arrow: GraphLinkArrowStyle.Double })), // Double-sided arrows
570
- ]).enter()
571
- .append('marker')
572
- .attr('id', d => this._getMarkerId(null, d.color, d.arrow))
573
- .attr('orient', 'auto')
574
- .attr('markerWidth', d => d.arrow === GraphLinkArrowStyle.Double ? LINK_MARKER_WIDTH * 2 : LINK_MARKER_WIDTH)
575
- .attr('markerHeight', d => d.arrow === GraphLinkArrowStyle.Double ? LINK_MARKER_HEIGHT * 2 : LINK_MARKER_HEIGHT)
576
- .attr('markerUnits', 'userSpaceOnUse')
577
- .attr('refX', LINK_MARKER_WIDTH - LINK_MARKER_HEIGHT / 2)
578
- .attr('refY', LINK_MARKER_HEIGHT - LINK_MARKER_HEIGHT / 2)
579
- .html(d => {
580
- var _a;
581
- return `
582
- <path
583
- d="${d.arrow === GraphLinkArrowStyle.Double ? getDoubleArrowPath() : getArrowPath()}"
584
- fill="${(_a = d.color) !== null && _a !== void 0 ? _a : null}"
585
- />
586
- `;
587
- });
579
+ // Single Arrow
580
+ this._defs.append('path').attr('d', getArrowPath())
581
+ .attr('id', this._getLinkArrowDefId(GraphLinkArrowStyle.Single));
582
+ // Double Arrow
583
+ this._defs.append('path').attr('d', getDoubleArrowPath())
584
+ .attr('id', this._getLinkArrowDefId(GraphLinkArrowStyle.Double));
588
585
  }
589
586
  zoomIn(increment = 0.3) {
590
587
  const scaleBy = 1 + increment;
@@ -600,8 +597,13 @@ class Graph extends ComponentCore {
600
597
  smartTransition(this.g, this.config.duration / 2)
601
598
  .call(this._zoomBehavior.scaleTo, zoomLevel);
602
599
  }
603
- fitView() {
604
- this._fit(this.config.duration / 2);
600
+ getZoom() {
601
+ return zoomTransform(this.g.node()).k;
602
+ }
603
+ fitView(duration = this.config.duration) {
604
+ this._layoutCalculationPromise.then(() => {
605
+ this._fit(duration);
606
+ });
605
607
  }
606
608
  /** Enable automatic fitting to container if it was disabled due to previous zoom / pan interactions */
607
609
  resetAutofitState() {
@@ -641,8 +643,10 @@ Graph.selectors = {
641
643
  nodeGauge: nodeGauge,
642
644
  nodeSideLabel: sideLabelGroup,
643
645
  nodeLabel: label,
646
+ dimmedNode: greyedOutNode,
644
647
  link: gLink,
645
648
  linkLine: link,
649
+ dimmedLink: greyedOutLink,
646
650
  panel: gPanel,
647
651
  panelRect: panel,
648
652
  panelSelection: panelSelection,