@unovis/ts 1.4.0-alpha.0 → 1.4.0-alpha.10

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 (38) hide show
  1. package/components/graph/config.d.ts +14 -4
  2. package/components/graph/config.js +4 -2
  3. package/components/graph/config.js.map +1 -1
  4. package/components/graph/index.d.ts +6 -1
  5. package/components/graph/index.js +100 -73
  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/index.js +5 -3
  10. package/components/graph/modules/link/index.js.map +1 -1
  11. package/components/graph/modules/link/style.d.ts +1 -1
  12. package/components/graph/modules/link/style.js +3 -3
  13. package/components/graph/modules/link/style.js.map +1 -1
  14. package/components/graph/modules/node/index.js +5 -4
  15. package/components/graph/modules/node/index.js.map +1 -1
  16. package/components/graph/modules/node/style.d.ts +1 -1
  17. package/components/graph/modules/node/style.js +7 -3
  18. package/components/graph/modules/node/style.js.map +1 -1
  19. package/components/graph/modules/shape.d.ts +0 -2
  20. package/components/graph/modules/shape.js +6 -9
  21. package/components/graph/modules/shape.js.map +1 -1
  22. package/components/graph/types.d.ts +16 -5
  23. package/components/graph/types.js +1 -0
  24. package/components/graph/types.js.map +1 -1
  25. package/components/tooltip/config.d.ts +1 -1
  26. package/components/tooltip/config.js.map +1 -1
  27. package/components/tooltip/index.js +3 -1
  28. package/components/tooltip/index.js.map +1 -1
  29. package/components/vis-controls/index.d.ts +3 -0
  30. package/components/vis-controls/index.js +6 -1
  31. package/components/vis-controls/index.js.map +1 -1
  32. package/core/component/index.d.ts +3 -3
  33. package/core/component/index.js +1 -1
  34. package/core/component/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/utils/svg.d.ts +1 -0
  37. package/utils/svg.js +10 -1
  38. package/utils/svg.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, GraphDagreLayoutSetting } 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,7 +56,7 @@ 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
  */
@@ -159,5 +159,15 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
159
159
  selectedNodeId?: number | string;
160
160
  /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */
161
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;
162
172
  }
163
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, 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 });
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 GraphDagreLayoutSetting,\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?: 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\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 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"],"names":[],"mappings":";;;;AAAA;MAqMa,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,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,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;
@@ -109,7 +113,8 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
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 */
@@ -12,15 +12,15 @@ import { GraphLayoutType, GraphLinkArrowStyle } from './types.js';
12
12
  import { GraphDefaultConfig } from './config.js';
13
13
  import { background, graphGroup, root } from './style.js';
14
14
  import * as style from './modules/node/style.js';
15
- import { nodes, gNode, gNodeExit, node, nodeGauge, sideLabelGroup, label } from './modules/node/style.js';
16
- 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';
17
17
  import { panels, gPanel, panel, panelSelection, label as label$1, labelText, sideIconGroup, sideIconShape, sideIconSymbol } from './modules/panel/style.js';
18
18
  import { createNodes, updateNodes, removeNodes, updateSelectedNodes, zoomNodesThrottled, zoomNodes } from './modules/node/index.js';
19
19
  import { getMaxNodeSize, getX, getY, getNodeSize } from './modules/node/helper.js';
20
20
  import { createLinks, updateLinks, removeLinks, updateSelectedLinks, animateLinkFlow, zoomLinksThrottled, zoomLinks } from './modules/link/index.js';
21
21
  import { getArrowPath, getDoubleArrowPath } from './modules/link/helper.js';
22
22
  import { removePanels, createPanels, updatePanels } from './modules/panel/index.js';
23
- import { initPanels, setPanelForNodes, updatePanelNumNodes, updatePanelBBoxSize } from './modules/panel/helper.js';
23
+ import { updatePanelNumNodes, updatePanelBBoxSize, initPanels, setPanelForNodes } from './modules/panel/helper.js';
24
24
  import { applyLayoutCircular, applyELKLayout, applyLayoutConcentric, applyLayoutForce, applyLayoutDagre, applyLayoutParallel } from './modules/layout.js';
25
25
 
26
26
  class Graph extends ComponentCore {
@@ -79,9 +79,9 @@ class Graph extends ComponentCore {
79
79
  this._addSVGDefs();
80
80
  }
81
81
  setConfig(config) {
82
- this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate(config);
83
- this._shouldFitLayout = this._shouldFitLayout || this._shouldRecalculateLayout;
84
82
  super.setConfig(config);
83
+ this._shouldRecalculateLayout = this._shouldRecalculateLayout || this._shouldLayoutRecalculate();
84
+ this._shouldFitLayout = this._shouldFitLayout || this._shouldRecalculateLayout;
85
85
  this._shouldSetPanels = true;
86
86
  }
87
87
  get bleed() {
@@ -89,7 +89,7 @@ class Graph extends ComponentCore {
89
89
  return { top: extraPadding, bottom: extraPadding, left: extraPadding, right: extraPadding };
90
90
  }
91
91
  _render(customDuration) {
92
- const { config: { disableZoom, duration, layoutAutofit, panels }, datamodel } = this;
92
+ const { config: { disableZoom, duration, layoutAutofit }, datamodel } = this;
93
93
  if (!datamodel.nodes && !datamodel.links)
94
94
  return;
95
95
  const animDuration = isNumber(customDuration) ? customDuration : duration;
@@ -104,18 +104,16 @@ class Graph extends ComponentCore {
104
104
  this._prevHeight = this._height;
105
105
  }
106
106
  // Apply layout and render
107
- this._calculateLayout().then((isFirstRender) => {
107
+ if (this._shouldRecalculateLayout || !this._layoutCalculationPromise) {
108
+ this._layoutCalculationPromise = this._calculateLayout();
109
+ }
110
+ this._layoutCalculationPromise.then((isFirstRender) => {
108
111
  // If the component has been destroyed while the layout calculation
109
112
  // was in progress, we cancel the render
110
113
  if (this.isDestroyed())
111
114
  return;
112
- if (this._shouldSetPanels) {
113
- smartTransition(this._panelsGroup, duration / 2)
114
- .style('opacity', (panels === null || panels === void 0 ? void 0 : panels.length) ? 1 : 0);
115
- this._panels = initPanels(panels);
116
- setPanelForNodes(this._panels, datamodel.nodes, this.config);
117
- this._shouldSetPanels = false;
118
- }
115
+ this._initPanelsData();
116
+ // Fit the view
119
117
  if (isFirstRender) {
120
118
  this._fit();
121
119
  this._shouldFitLayout = false;
@@ -211,7 +209,10 @@ class Graph extends ComponentCore {
211
209
  .call(removeLinks, config, duration);
212
210
  }
213
211
  _drawPanels(nodeUpdateSelection, duration) {
212
+ var _a;
214
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);
215
216
  if (!this._panels)
216
217
  return;
217
218
  const selection = (nodeUpdateSelection.duration)
@@ -238,51 +239,58 @@ class Graph extends ComponentCore {
238
239
  panelToUpdate.call(updatePanels, config, duration);
239
240
  }
240
241
  _calculateLayout() {
242
+ var _a, _b;
241
243
  return __awaiter(this, void 0, void 0, function* () {
242
244
  const { config, datamodel } = this;
243
245
  const firstRender = this._isFirstRender;
244
- if (this._shouldRecalculateLayout) {
245
- switch (config.layoutType) {
246
- case GraphLayoutType.Parallel:
247
- applyLayoutParallel(datamodel, config, this._width, this._height);
248
- break;
249
- case GraphLayoutType.ParallelHorizontal:
250
- applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal');
251
- break;
252
- case GraphLayoutType.Dagre:
253
- yield applyLayoutDagre(datamodel, config, this._width);
254
- break;
255
- case GraphLayoutType.Force:
256
- yield applyLayoutForce(datamodel, config, this._width);
257
- break;
258
- case GraphLayoutType.Concentric:
259
- applyLayoutConcentric(datamodel, config, this._width, this._height);
260
- break;
261
- case GraphLayoutType.Elk:
262
- yield applyELKLayout(datamodel, config, this._width);
263
- break;
264
- case GraphLayoutType.Circular:
265
- default:
266
- applyLayoutCircular(datamodel, config, this._width, this._height);
267
- break;
268
- }
269
- 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;
270
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;
271
277
  return firstRender;
272
278
  });
273
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
+ }
274
288
  _fit(duration = 0) {
275
- var _a;
276
289
  const { datamodel: { nodes } } = this;
277
- if ((nodes === null || nodes === void 0 ? void 0 : nodes.length) && ((_a = this.g) === null || _a === void 0 ? void 0 : _a.size())) {
278
- const transform = this._getTransform(nodes);
279
- smartTransition(this.g, duration)
280
- .call(this._zoomBehavior.transform, transform);
281
- this._onZoom(transform);
282
- }
283
- else {
284
- console.warn('Unovis | Graph: Node data is not defined. Check if the component has been initialized.');
285
- }
290
+ const transform = this._getTransform(nodes);
291
+ smartTransition(this.g, duration)
292
+ .call(this._zoomBehavior.transform, transform);
293
+ this._onZoom(transform);
286
294
  }
287
295
  _getTransform(nodes) {
288
296
  const { nodeSize, zoomScaleExtent } = this.config;
@@ -291,13 +299,17 @@ class Graph extends ComponentCore {
291
299
  const w = this._width;
292
300
  const h = this._height;
293
301
  const xExtent = [
294
- 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); }),
295
- 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)),
296
304
  ];
297
305
  const yExtent = [
298
- 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); }),
299
- 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)),
300
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
+ }
301
313
  const xScale = w / (xExtent[1] - xExtent[0] + left + right);
302
314
  const yScale = h / (yExtent[1] - yExtent[0] + top + bottom);
303
315
  const clampedScale = clamp(min([xScale, yScale]), zoomScaleExtent[0], zoomScaleExtent[1]);
@@ -440,7 +452,8 @@ class Graph extends ComponentCore {
440
452
  this._scale = transform.k;
441
453
  this._graphGroup.attr('transform', transform.toString());
442
454
  if (isFunction(config.onZoom))
443
- config.onZoom(this._scale, config.zoomScaleExtent);
455
+ config.onZoom(this._scale, config.zoomScaleExtent, event);
456
+ // console.warn('Unovis | Graph: Zoom: ', transform)
444
457
  if (!this._initialTransform)
445
458
  this._initialTransform = transform;
446
459
  // If the event was triggered by a mouse interaction (pan or zoom) we don't
@@ -450,7 +463,9 @@ class Graph extends ComponentCore {
450
463
  const propVal = transform[prop];
451
464
  const initialPropVal = this._initialTransform[prop];
452
465
  const dVal = Math.abs(propVal - initialPropVal);
453
- return prop === 'k' ? 2 * dVal : dVal / 50;
466
+ const scaledDVal = prop === 'k' ? 20 * dVal : dVal / 15;
467
+ acc += scaledDVal;
468
+ return acc;
454
469
  }, 0);
455
470
  if (diff > config.layoutAutofitTolerance)
456
471
  this._isAutoFitDisabled = true;
@@ -463,13 +478,15 @@ class Graph extends ComponentCore {
463
478
  .call((nodes.length > config.zoomThrottledUpdateNodeThreshold ? zoomLinksThrottled : zoomLinks), config, this._scale, this._getLinkArrowDefId);
464
479
  }
465
480
  _onDragStarted(d, event, nodeSelection) {
481
+ var _a;
466
482
  const { config } = this;
467
483
  this._isDragging = true;
468
484
  d._state.isDragged = true;
469
485
  nodeSelection.call(updateNodes, config, 0, this._scale);
486
+ (_a = config.onNodeDragStart) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
470
487
  }
471
488
  _onDragged(d, event, allNodesSelection) {
472
- var _a, _b;
489
+ var _a, _b, _c;
473
490
  const { config } = this;
474
491
  const transform = zoomTransform(this.g.node());
475
492
  const scale = transform.k;
@@ -515,37 +532,40 @@ class Graph extends ComponentCore {
515
532
  const linksToAnimate = linksToUpdate.filter(d => d._state.greyout);
516
533
  if (linksToAnimate.size())
517
534
  animateLinkFlow(linksToAnimate, config, this._scale);
535
+ (_c = config.onNodeDrag) === null || _c === void 0 ? void 0 : _c.call(config, d, event);
518
536
  }
519
537
  _onDragEnded(d, event, nodeSelection) {
538
+ var _a;
520
539
  const { config } = this;
521
540
  this._isDragging = false;
522
541
  d._state.isDragged = false;
523
542
  nodeSelection.call(updateNodes, config, 0, this._scale);
543
+ (_a = config.onNodeDragEnd) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
524
544
  }
525
- _shouldLayoutRecalculate(nextConfig) {
526
- const { config } = this;
527
- if (config.layoutType !== nextConfig.layoutType)
545
+ _shouldLayoutRecalculate() {
546
+ const { prevConfig, config } = this;
547
+ if (prevConfig.layoutType !== config.layoutType)
528
548
  return true;
529
- if (config.layoutNonConnectedAside !== nextConfig.layoutNonConnectedAside)
549
+ if (prevConfig.layoutNonConnectedAside !== config.layoutNonConnectedAside)
530
550
  return true;
531
- if (config.layoutType === GraphLayoutType.Force) {
532
- const forceSettingsDiff = shallowDiff(config.forceLayoutSettings, nextConfig.forceLayoutSettings);
551
+ if (prevConfig.layoutType === GraphLayoutType.Force) {
552
+ const forceSettingsDiff = shallowDiff(prevConfig.forceLayoutSettings, config.forceLayoutSettings);
533
553
  if (Object.keys(forceSettingsDiff).length)
534
554
  return true;
535
555
  }
536
- if (config.layoutType === GraphLayoutType.Dagre) {
537
- const dagreSettingsDiff = shallowDiff(config.dagreLayoutSettings, nextConfig.dagreLayoutSettings);
556
+ if (prevConfig.layoutType === GraphLayoutType.Dagre) {
557
+ const dagreSettingsDiff = shallowDiff(prevConfig.dagreLayoutSettings, config.dagreLayoutSettings);
538
558
  if (Object.keys(dagreSettingsDiff).length)
539
559
  return true;
540
560
  }
541
- if (config.layoutType === GraphLayoutType.Parallel ||
542
- config.layoutType === GraphLayoutType.ParallelHorizontal ||
543
- config.layoutType === GraphLayoutType.Concentric) {
544
- 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)
545
565
  return true;
546
- if (config.layoutParallelNodesPerColumn !== nextConfig.layoutParallelNodesPerColumn)
566
+ if (prevConfig.layoutParallelNodesPerColumn !== config.layoutParallelNodesPerColumn)
547
567
  return true;
548
- if (config.layoutParallelSortConnectionsByGroup !== nextConfig.layoutParallelSortConnectionsByGroup)
568
+ if (prevConfig.layoutParallelSortConnectionsByGroup !== config.layoutParallelSortConnectionsByGroup)
549
569
  return true;
550
570
  }
551
571
  return false;
@@ -577,8 +597,13 @@ class Graph extends ComponentCore {
577
597
  smartTransition(this.g, this.config.duration / 2)
578
598
  .call(this._zoomBehavior.scaleTo, zoomLevel);
579
599
  }
580
- fitView() {
581
- 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
+ });
582
607
  }
583
608
  /** Enable automatic fitting to container if it was disabled due to previous zoom / pan interactions */
584
609
  resetAutofitState() {
@@ -618,8 +643,10 @@ Graph.selectors = {
618
643
  nodeGauge: nodeGauge,
619
644
  nodeSideLabel: sideLabelGroup,
620
645
  nodeLabel: label,
646
+ dimmedNode: greyedOutNode,
621
647
  link: gLink,
622
648
  linkLine: link,
649
+ dimmedLink: greyedOutLink,
623
650
  panel: gPanel,
624
651
  panelRect: panel,
625
652
  panelSelection: panelSelection,