@neo4j-nvl/base 0.3.1-016fc371
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +49 -0
- package/README.md +43 -0
- package/dist/base.mjs +2 -0
- package/dist/base.mjs.LICENSE.txt +10 -0
- package/dist/types/index.d.ts +379 -0
- package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +25 -0
- package/dist/types/layouts/animatedlayout/animationUtils.d.ts +9 -0
- package/dist/types/layouts/d3forcelayout/circularLayout.d.ts +5 -0
- package/dist/types/layouts/d3forcelayout/constants.d.ts +18 -0
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +29 -0
- package/dist/types/layouts/d3forcelayout/types.d.ts +9 -0
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +22 -0
- package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +32 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +167 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/glwrapper.d.ts +4 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +43 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +2 -0
- package/dist/types/layouts/freeLayout/FreeLayout.d.ts +26 -0
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +16 -0
- package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +26 -0
- package/dist/types/layouts/hierarchicallayout/constants.d.ts +11 -0
- package/dist/types/modules/CallbackHelper.d.ts +38 -0
- package/dist/types/modules/ExternalCallbackHandler.d.ts +26 -0
- package/dist/types/modules/NvlController.d.ts +114 -0
- package/dist/types/modules/Shader.d.ts +18 -0
- package/dist/types/modules/ZoomTransitionHandler.d.ts +27 -0
- package/dist/types/modules/dataset.d.ts +37 -0
- package/dist/types/modules/logging.d.ts +8 -0
- package/dist/types/modules/performance.d.ts +93 -0
- package/dist/types/modules/state.d.ts +242 -0
- package/dist/types/renderers/canvasrenderer/Animation.d.ts +64 -0
- package/dist/types/renderers/canvasrenderer/AnimationHandler.d.ts +72 -0
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +92 -0
- package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +11 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.d.ts +79 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.d.ts +33 -0
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +51 -0
- package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +41 -0
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +58 -0
- package/dist/types/renderers/canvasrenderer/types.d.ts +47 -0
- package/dist/types/renderers/canvasrenderer/util.d.ts +69 -0
- package/dist/types/renderers/canvasrenderer/vectorUtils.d.ts +21 -0
- package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +42 -0
- package/dist/types/renderers/webglrenderer/Controller.d.ts +66 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +51 -0
- package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +2 -0
- package/dist/types/types/graph-element.d.ts +114 -0
- package/dist/types/types/nvl-window-functions.d.ts +14 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/utils/canvasManagement.d.ts +15 -0
- package/dist/types/utils/colorMapperFunctions.d.ts +6 -0
- package/dist/types/utils/constants.d.ts +30 -0
- package/dist/types/utils/errors.d.ts +11 -0
- package/dist/types/utils/geometry.d.ts +122 -0
- package/dist/types/utils/graphObjectUtils.d.ts +9 -0
- package/dist/types/utils/hittest.d.ts +56 -0
- package/dist/types/utils/mouseUtils.d.ts +9 -0
- package/dist/types/utils/zoomFunctions.d.ts +20 -0
- package/package.json +64 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Lodash <https://lodash.com/>
|
|
6
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
7
|
+
* Released under MIT license <https://lodash.com/license>
|
|
8
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
9
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
10
|
+
*/
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
|
|
2
|
+
import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state';
|
|
3
|
+
import { ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, d3ForceLayoutType } from './modules/state';
|
|
4
|
+
import { drawCircleBand } from './renderers/canvasrenderer/util';
|
|
5
|
+
import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
|
|
6
|
+
import { CompatibilityError } from './utils/errors';
|
|
7
|
+
import type { Point } from './utils/geometry';
|
|
8
|
+
import type { HitTargetNode, HitTargetRelationship, HitTargets } from './utils/hittest';
|
|
9
|
+
/**
|
|
10
|
+
* Extends the MouseEvent interface with the {@link HitTargets} property.
|
|
11
|
+
* The result of a _.{@link NVL.getHits} call.
|
|
12
|
+
*/
|
|
13
|
+
interface NvlMouseEvent extends MouseEvent {
|
|
14
|
+
nvlTargets: HitTargets;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Class for a NVL instance.
|
|
18
|
+
* @example
|
|
19
|
+
* This is a basic setup for a NVL instance.
|
|
20
|
+
* ```js
|
|
21
|
+
* const nodes = [
|
|
22
|
+
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
23
|
+
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
24
|
+
* ]
|
|
25
|
+
* const relationships = [
|
|
26
|
+
* { id: '12', from: '1', to: '2' }
|
|
27
|
+
* ]
|
|
28
|
+
* const options = {
|
|
29
|
+
* layout: 'hierarchical',
|
|
30
|
+
* initialZoom: 0.5
|
|
31
|
+
* }
|
|
32
|
+
* const callbacks = {
|
|
33
|
+
* onLayoutDone: () => console.log('Layout done')
|
|
34
|
+
* }
|
|
35
|
+
* const nvl = new NVL(document.getElementById('frame'), nodes, relationships, options, callbacks)
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare class NVL {
|
|
39
|
+
private readonly externalCallbackHandler;
|
|
40
|
+
private readonly performance;
|
|
41
|
+
private visState;
|
|
42
|
+
private nvlController;
|
|
43
|
+
private options;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new NVL instance.
|
|
46
|
+
* @constructor
|
|
47
|
+
* @param {HTMLElement} frame - The DOM element to display the graph in
|
|
48
|
+
* @param {Node[]} nvlNodes - An Array of nodes
|
|
49
|
+
* @param {Relationship[]} nvlRels - An Array of relationships
|
|
50
|
+
* @param {NvlOptions} options - Options for the NVL instance
|
|
51
|
+
* @param {ExternalCallbackHandler} callbacks - Callbacks triggered on NVL events
|
|
52
|
+
*/
|
|
53
|
+
constructor(frame: HTMLElement, nvlNodes?: Node[], nvlRels?: Relationship[], options?: NvlOptions, callbacks?: ExternalCallbacks);
|
|
54
|
+
/**
|
|
55
|
+
* Restarts the NVL instance.
|
|
56
|
+
* @param {NvlOptions} options - new options for the NVL instance
|
|
57
|
+
* @param {boolean} retainPositions - whether or not to retain the current node positions
|
|
58
|
+
* @note new options will be merged with current options
|
|
59
|
+
*/
|
|
60
|
+
restart(options?: NvlOptions, retainPositions?: boolean): void;
|
|
61
|
+
/**
|
|
62
|
+
* Adds nodes and relationships to NVL and updates existing nodes and relationships.
|
|
63
|
+
* @param {Node[] | PartialNode[]} nodes - An Array of nodes to be added or updated
|
|
64
|
+
* @param {Relationship[] | PartialRelationship[]} relationships - An Array of relationships to be added or updated
|
|
65
|
+
* @note To update nodes or relationships, they must have an id that matches the id of the
|
|
66
|
+
* node or relationship to be updated.
|
|
67
|
+
* @note Only the properties that are provided will be updated.
|
|
68
|
+
* If an existing property is not provided, it will not be changed.
|
|
69
|
+
* @example
|
|
70
|
+
* Adding and updating nodes and relationships
|
|
71
|
+
* ```js
|
|
72
|
+
* const nodes = [
|
|
73
|
+
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
74
|
+
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
75
|
+
* ]
|
|
76
|
+
* const relationships = [
|
|
77
|
+
* { id: '12', from: '1', to: '2' }
|
|
78
|
+
* ]
|
|
79
|
+
* // Adds new nodes and relationships
|
|
80
|
+
* nvl.addAndUpdateElementsInGraph(nodes, relationships)
|
|
81
|
+
* // Updates an existing relationship
|
|
82
|
+
* nvl.addAndUpdateElementsInGraph([], [{ id: '12', color: '#e0df41' }])
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
addAndUpdateElementsInGraph(nodes?: Node[] | PartialNode[], relationships?: Relationship[] | PartialRelationship[]): void;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the currently selected nodes.
|
|
88
|
+
* @returns {(Node & Point)[]} An array of all currently selected nodes and their positions.
|
|
89
|
+
*/
|
|
90
|
+
getSelectedNodes(): (Node & Point)[];
|
|
91
|
+
/**
|
|
92
|
+
* Gets the currently selected relationships.
|
|
93
|
+
* @returns {Relationship[]} An array of all currently selected relationships.
|
|
94
|
+
*/
|
|
95
|
+
getSelectedRelationships(): Relationship[];
|
|
96
|
+
/**
|
|
97
|
+
* Updates relationships in the current scene with the provided array of nodes and relationships.
|
|
98
|
+
* @param {Node[] | PartialNode[]} nodes The updated nodes.
|
|
99
|
+
* @param {Relationship[] | PartialRelationship[]} relationships The updated relationships.
|
|
100
|
+
* @note ignores any nodes or relationships that do not exist in the current scene.
|
|
101
|
+
* @note To update nodes or relationships, they must have an id that matches the id of the
|
|
102
|
+
* node or relationship to be updated.
|
|
103
|
+
* @note Only the properties that are provided will be updated.
|
|
104
|
+
* If an existing property is not provided, it will not be changed.
|
|
105
|
+
* @example
|
|
106
|
+
* Updating nodes and relationships
|
|
107
|
+
* ```js
|
|
108
|
+
* const nodes = [
|
|
109
|
+
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
110
|
+
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
111
|
+
* ]
|
|
112
|
+
* const relationships = [
|
|
113
|
+
* { id: '12', from: '1', to: '2' }
|
|
114
|
+
* ]
|
|
115
|
+
* const nvl = new NVL(container, nodes, relationships)
|
|
116
|
+
* // Updates an existing node and relationship
|
|
117
|
+
* nvl.updateElementsInGraph([{ id: '1', selected: true }], [{ id: '12', color: '#e0df41' }])
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
updateElementsInGraph(nodes: Node[] | PartialNode[], relationships: Relationship[] | PartialRelationship[]): void;
|
|
121
|
+
/**
|
|
122
|
+
* Adds nodes and relationships in the current scene.
|
|
123
|
+
* @param {Node[]} nodes The nodes to be added.
|
|
124
|
+
* @param {Relationship[]} relationships The relationships to be added.
|
|
125
|
+
*/
|
|
126
|
+
addElementsToGraph(nodes: Node[], relationships: Relationship[]): void;
|
|
127
|
+
/**
|
|
128
|
+
* Removes the specified nodes from the current scene.
|
|
129
|
+
* @param {string[]} nodeIds The node ids to be removed.
|
|
130
|
+
* @note adjacent relationships will also be removed.
|
|
131
|
+
*/
|
|
132
|
+
removeNodesWithIds(nodeIds: string[]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Removes the specified relationships from the current scene.
|
|
135
|
+
* @param {string[]} relationshipIds The relationship ids to be removed.
|
|
136
|
+
*/
|
|
137
|
+
removeRelationshipsWithIds(relationshipIds: string[]): void;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the node data that is currently stored in the visualisation for a given id.
|
|
140
|
+
* @param {string} id The id of the node that should be returned.
|
|
141
|
+
* @returns {Node} The node or undefined if there is no node with the given id.
|
|
142
|
+
*/
|
|
143
|
+
getNodes(): Node[];
|
|
144
|
+
/**
|
|
145
|
+
* Returns the relationships that are currently in the visualization.
|
|
146
|
+
* @returns {Relationship[]} An array of the relationships in the visualization.
|
|
147
|
+
*/
|
|
148
|
+
getRelationships(): Relationship[];
|
|
149
|
+
/**
|
|
150
|
+
* Returns the node data that is currently stored in the visualisation for a given id.
|
|
151
|
+
* @param {string} id The id of the node that should be returned.
|
|
152
|
+
* @returns {Node} The node or undefined if there is no node with the given id.
|
|
153
|
+
*/
|
|
154
|
+
getNodeById(id: string): Node;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the relationship data that is currently stored in the visualisation for a given id.
|
|
157
|
+
* @param {string} id The id of the relationship that should be returned.
|
|
158
|
+
* @returns {Relationship} The relationship or undefined if there is no relationship with the given id.
|
|
159
|
+
*/
|
|
160
|
+
getRelationshipById(id: string): Relationship;
|
|
161
|
+
/**
|
|
162
|
+
* Returns the node position that is currently stored in the visualisation for a given id.
|
|
163
|
+
* @param {string} id The id of the node position that should be returned.
|
|
164
|
+
* @returns {Node} The position information for the given id, or undefined if there is no such node
|
|
165
|
+
* or the layout has not yet run with that node.
|
|
166
|
+
*/
|
|
167
|
+
getPositionById(id: string): Node;
|
|
168
|
+
/**
|
|
169
|
+
* Returns the current options.
|
|
170
|
+
* @returns {NvlOptions} The current options.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
getCurrentOptions(): NvlOptions;
|
|
174
|
+
/** Removes the graph visualization from the DOM and cleans up everything. */
|
|
175
|
+
destroy(): void;
|
|
176
|
+
/**
|
|
177
|
+
* De-selects all nodes and relationships.
|
|
178
|
+
*/
|
|
179
|
+
deselectAll(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Updates pan and zoom fit the specified nodes in the viewport.
|
|
182
|
+
* @param {string[]} nodeIds The ids of the nodes to fit on the screen,
|
|
183
|
+
* @param {NvlState['zoomOptions']} zoomOptions specific options on how to transition the zoom
|
|
184
|
+
* @note If the zoom level required to fit the provided nodes is outside of the range provided by the
|
|
185
|
+
* {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
|
|
186
|
+
* and {@link NvlOptions.allowDynamicMinZoom} is set to `false`,
|
|
187
|
+
* the zoom level will be set to the closest valid zoom level,
|
|
188
|
+
* even if the given nodes do not fit the viewport yet.
|
|
189
|
+
*/
|
|
190
|
+
fit(nodeIds: string[], zoomOptions: NvlState['zoomOptions']): void;
|
|
191
|
+
/**
|
|
192
|
+
* Resets the zoom of the viewport back to the default zoom level of 0.75
|
|
193
|
+
*/
|
|
194
|
+
resetZoom(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Toggles between the WebGL and Canvas rendering.
|
|
197
|
+
* @deprecated use {@link setRenderer} instead.
|
|
198
|
+
* @param {boolean} enabled Whether or not WebGL renderer should be used.
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
setUseWebGLRenderer(enabled: boolean): void;
|
|
202
|
+
/**
|
|
203
|
+
* Switches between rendering methods
|
|
204
|
+
* @param renderer - which rendering method to use
|
|
205
|
+
*/
|
|
206
|
+
setRenderer(renderer: string): void;
|
|
207
|
+
/**
|
|
208
|
+
* Restarts NVL with or without WebGL support.
|
|
209
|
+
* @param {boolean} disabled Whether or not WebGL should be disabled.
|
|
210
|
+
* @note not to be confused with {@link setUseWebGLRenderer}, which only affects the rendering method
|
|
211
|
+
* @experimental
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
setDisableWebGL(disabled?: boolean): void;
|
|
215
|
+
/**
|
|
216
|
+
* Pins the specified node so it is not affected by layout forces.
|
|
217
|
+
* @param {string} nodeId The id of the node to be pinned.
|
|
218
|
+
*/
|
|
219
|
+
pinNode(nodeId: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Un-pins the specified nodes so it is affected by layout forces again.
|
|
222
|
+
* @param {string[]} nodeIds The ids of the nodes to be un-pinned.
|
|
223
|
+
*/
|
|
224
|
+
unPinNode(nodeIds: string[]): void;
|
|
225
|
+
/**
|
|
226
|
+
* Changes the layout type.
|
|
227
|
+
* @param {Layout} layout The layout type.
|
|
228
|
+
*/
|
|
229
|
+
setLayout(layout: Layout): void;
|
|
230
|
+
/**
|
|
231
|
+
* Updates the configuration of the current layout.
|
|
232
|
+
* @param {LayoutOptions} options The layout configuration.
|
|
233
|
+
*/
|
|
234
|
+
setLayoutOptions(options: LayoutOptions): void;
|
|
235
|
+
/**
|
|
236
|
+
* Returns the nodes that are currently in the visualization.
|
|
237
|
+
* @note The `rels` property of the returned object is always empty.
|
|
238
|
+
* @returns {{ nodes: Node[], rels: Relationship [] }} An array of the nodes in the visualization.
|
|
239
|
+
*/
|
|
240
|
+
getNodesOnScreen(): {
|
|
241
|
+
nodes: Node[];
|
|
242
|
+
rels: Relationship[];
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Fetches and returns the current positions of all nodes as an array of coordinates.
|
|
246
|
+
* @returns {(Node & Point)[]} An array of node positions.
|
|
247
|
+
*/
|
|
248
|
+
getNodePositions(): (Node & Point)[];
|
|
249
|
+
/**
|
|
250
|
+
* Sets the node positions based on data provided
|
|
251
|
+
* @param {Node[]} data The positions that the nodes should be set to.
|
|
252
|
+
* @param {boolean} updateLayout whether or not the current layout algorithm
|
|
253
|
+
* should update the graph after setting the node positions.
|
|
254
|
+
* False by default.
|
|
255
|
+
*/
|
|
256
|
+
setNodePositions(data: Node[], updateLayout?: boolean): void;
|
|
257
|
+
/**
|
|
258
|
+
* Checks and returns whether the current layout is still in flux.
|
|
259
|
+
* @returns {boolean} Whether or not the layout is moving.
|
|
260
|
+
*/
|
|
261
|
+
isLayoutMoving(): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Saves the current view of the graph visualization canvas as a png to the client.
|
|
264
|
+
* @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
|
|
265
|
+
* @param {string} options.filename The filename of the png file.
|
|
266
|
+
* @param {string} options.backgroundColor - The background color of the png file.
|
|
267
|
+
* @note The size of the png file will be the size of the canvas in the DOM.
|
|
268
|
+
*/
|
|
269
|
+
saveToFile(options: {
|
|
270
|
+
filename?: string;
|
|
271
|
+
backgroundColor?: string;
|
|
272
|
+
}): void;
|
|
273
|
+
/**
|
|
274
|
+
* Saves the entire graph visualization canvas as a png to the client.
|
|
275
|
+
* @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
|
|
276
|
+
* @param {string} options.filename The filename of the png file.
|
|
277
|
+
* @param {string} options.backgroundColor - The background color of the png file.
|
|
278
|
+
* @note The size of the png file will be as large as the entire graph at the default zoom level.
|
|
279
|
+
* Can result in a very large file.
|
|
280
|
+
* @example
|
|
281
|
+
* // Save the entire graph visualization canvas as a png to the client.
|
|
282
|
+
* graphVisualization.saveFullGraphToFile({ filename: 'graph.png', backgroundColor: '#fff' })
|
|
283
|
+
*/
|
|
284
|
+
saveFullGraphToLargeFile(options: {
|
|
285
|
+
filename?: string;
|
|
286
|
+
backgroundColor?: string;
|
|
287
|
+
}): void;
|
|
288
|
+
/**
|
|
289
|
+
* Sets the zoom of the viewport to a specific value.
|
|
290
|
+
* @param {number} absolute The desired zoom level.
|
|
291
|
+
* @note When updating both the zoom level and pan coordinates,
|
|
292
|
+
* use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
|
|
293
|
+
* separately to avoid jittering.
|
|
294
|
+
* @note If the zoom level is outside of the range provided by the
|
|
295
|
+
* {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
|
|
296
|
+
* the zoom level will be set to the closest valid zoom level.
|
|
297
|
+
* @note If {@link NvlOptions.allowDynamicMinZoom} is set to true,
|
|
298
|
+
* the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
|
|
299
|
+
*/
|
|
300
|
+
setZoom(absolute: number): void;
|
|
301
|
+
/**
|
|
302
|
+
* Sets the zoom of the viewport to a specific value.
|
|
303
|
+
* @param {number} panX The desired panX value.
|
|
304
|
+
* @param {number} panY The desired panY value.
|
|
305
|
+
* @note When updating both the zoom level and pan coordinates,
|
|
306
|
+
* use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
|
|
307
|
+
* separately to avoid jittering.
|
|
308
|
+
*/
|
|
309
|
+
setPan(panX: number, panY: number): void;
|
|
310
|
+
/**
|
|
311
|
+
* Sets the zoom and pan of the viewport to specific values.
|
|
312
|
+
* @param {number} zoom The desired zoom level.
|
|
313
|
+
* @param {number} panX The desired panX value.
|
|
314
|
+
* @param {number} panY The desired panY value.
|
|
315
|
+
* @note When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
|
|
316
|
+
* @note If the zoom level is outside of the range provided by the
|
|
317
|
+
* {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
|
|
318
|
+
* the zoom level will be set to the closest valid zoom level.
|
|
319
|
+
* @note If {@link NvlOptions.allowDynamicMinZoom} is set to true,
|
|
320
|
+
* the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
|
|
321
|
+
*/
|
|
322
|
+
setZoomAndPan(zoom: number, panX: number, panY: number): void;
|
|
323
|
+
/**
|
|
324
|
+
* Get the current zoom level of the viewport.
|
|
325
|
+
* @returns {number} The current zoom level
|
|
326
|
+
*/
|
|
327
|
+
getScale(): number;
|
|
328
|
+
/**
|
|
329
|
+
* Returns the current pan of the viewport.
|
|
330
|
+
* @returns {Point} The current pan of the viewport.
|
|
331
|
+
*/
|
|
332
|
+
getPan(): Point;
|
|
333
|
+
/**
|
|
334
|
+
* Gets the nodes and relationships that have been hit by a pointer event.
|
|
335
|
+
* @param evt The mouse event.
|
|
336
|
+
* @param targets The graph elements to check for hits. Defaults to ['node', 'relationship'].
|
|
337
|
+
* @param hitOptions - Options for the hit test.
|
|
338
|
+
* @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
|
|
339
|
+
* containing the nodes and relationships that have been hit by the pointer event.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```js
|
|
343
|
+
* const container = document.getElementById('frame')
|
|
344
|
+
* const nvl = new NVL(container, nodes, relationships)
|
|
345
|
+
*
|
|
346
|
+
* // Get the nodes and relationships that have been hit by a pointer event.
|
|
347
|
+
* container.addEventListener('click', (evt) => {
|
|
348
|
+
* const { nvlTargets } = nvl.getHits(evt)
|
|
349
|
+
* console.log('clicked elements:', nvlTargets)
|
|
350
|
+
* })
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
getHits(evt: MouseEvent, targets?: ('node' | 'relationship')[], hitOptions?: {
|
|
354
|
+
hitNodeMarginWidth: number;
|
|
355
|
+
}): NvlMouseEvent;
|
|
356
|
+
/**
|
|
357
|
+
* Provides the container DOM element the graph is rendered in.
|
|
358
|
+
* @returns The container element of the NVL instance.
|
|
359
|
+
*/
|
|
360
|
+
getContainer(): HTMLElement;
|
|
361
|
+
private initialise;
|
|
362
|
+
private setupLogging;
|
|
363
|
+
private nodeRemoval;
|
|
364
|
+
private edgeRemoval;
|
|
365
|
+
private update;
|
|
366
|
+
private validateNodes;
|
|
367
|
+
private validateRelationships;
|
|
368
|
+
private checkWebGLCompatibility;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Functions for mapping colors.
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
declare const colorMapperFunctions: {
|
|
375
|
+
textColorForBackground: (color: string) => string;
|
|
376
|
+
};
|
|
377
|
+
export default NVL;
|
|
378
|
+
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions };
|
|
379
|
+
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NvlState } from '../../modules/state';
|
|
2
|
+
import type { Node } from '../../types/graph-element';
|
|
3
|
+
export default class AnimatedLayout {
|
|
4
|
+
positions: Record<string, Node>;
|
|
5
|
+
oldPositions: Record<string, Node>;
|
|
6
|
+
startTime: number;
|
|
7
|
+
t: number;
|
|
8
|
+
currentT: number;
|
|
9
|
+
state: NvlState;
|
|
10
|
+
shouldUpdateAnimator: boolean;
|
|
11
|
+
parents: Record<string, string>;
|
|
12
|
+
animationCompleteCallback: () => void;
|
|
13
|
+
shouldUpdate: boolean;
|
|
14
|
+
constructor(config: {
|
|
15
|
+
state: NvlState;
|
|
16
|
+
animationCompleteCallback?: () => void;
|
|
17
|
+
});
|
|
18
|
+
private getPositionMapFromState;
|
|
19
|
+
updatePositionsFromState(): void;
|
|
20
|
+
updateOldPositionFromState(): void;
|
|
21
|
+
startAnimation(): void;
|
|
22
|
+
update(): void;
|
|
23
|
+
updateNodes(positionList: Node[]): void;
|
|
24
|
+
getNodePositions(nodeList: Node[]): Node[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Node } from '../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../utils/geometry';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the average node coordinates for a given set of nodes.
|
|
5
|
+
* @param {Node[]} nodes The nodes to calculate the average position for.
|
|
6
|
+
* @param {Record<string, Node | Point>} positions The positions of the nodes.
|
|
7
|
+
* @returns {number[]} The average node coordinates.
|
|
8
|
+
*/
|
|
9
|
+
export declare const calculateAverageNodePosition: (nodes: Node[], positions: Record<string, Node | Point>) => number[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SimulationLinkDatum } from 'd3-force';
|
|
2
|
+
import type { D3Node } from './types';
|
|
3
|
+
export declare const VELOCITY_DECAY = 0.4;
|
|
4
|
+
export declare const DEFAULT_ALPHA = 1;
|
|
5
|
+
export declare const DEFAULT_ALPHA_TARGET = 0;
|
|
6
|
+
export declare const DEFAULT_ALPHA_MIN = 0.05;
|
|
7
|
+
export declare const DRAGGING_ALPHA = 0.2;
|
|
8
|
+
export declare const MAX_PRECOMPUTED_TICKS = 200;
|
|
9
|
+
export declare const MAX_STABILIZE_TICKS = 100;
|
|
10
|
+
export declare const LINK_DISTANCE = 45;
|
|
11
|
+
export declare const BARNES_HUT_THETA = 1.2;
|
|
12
|
+
export declare const FORCE_LINK_DISTANCE: (relationship: SimulationLinkDatum<D3Node>) => number;
|
|
13
|
+
export declare const FORCE_COLLIDE_RADIUS: (node: D3Node) => number;
|
|
14
|
+
export declare const LAYOUT_RADIUS: (numberOfNodes: number) => number;
|
|
15
|
+
export declare const FORCE_CHARGE: () => number;
|
|
16
|
+
export declare const FORCE_CHARGE_START: () => number;
|
|
17
|
+
export declare const FORCE_CENTER_X = 0.03;
|
|
18
|
+
export declare const FORCE_CENTER_Y = 0.03;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class d3ForceLayout {
|
|
2
|
+
constructor(config: any);
|
|
3
|
+
state: any;
|
|
4
|
+
d3Nodes: {};
|
|
5
|
+
d3RelList: {};
|
|
6
|
+
computing: boolean;
|
|
7
|
+
center: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
simulation: import("d3-force").Simulation<import("d3-force").SimulationNodeDatum, undefined>;
|
|
12
|
+
simulationStopped: boolean;
|
|
13
|
+
shouldUpdate: boolean;
|
|
14
|
+
stateDisposers: any[];
|
|
15
|
+
setOptions(options: any): void;
|
|
16
|
+
updateNodes(positionList: any): void;
|
|
17
|
+
update(refreshPositions?: boolean): void;
|
|
18
|
+
layout(_nodes: any, _rels: any, firstTimeAddingNodes: any): void;
|
|
19
|
+
getNodePositions(nodeList: any): {
|
|
20
|
+
id: any;
|
|
21
|
+
x: any;
|
|
22
|
+
y: any;
|
|
23
|
+
}[];
|
|
24
|
+
getShouldUpdate(): boolean;
|
|
25
|
+
getComputing(): boolean;
|
|
26
|
+
terminateUpdate(): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
setAlpha(alpha: any): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const ForceDirectedLayoutType = "forceDirected";
|
|
2
|
+
export declare const CoseBilkentType = "coseBilkent";
|
|
3
|
+
export declare class ForceCytoLayout {
|
|
4
|
+
private readonly physLayout;
|
|
5
|
+
private readonly coseBilkentLayout;
|
|
6
|
+
private readonly state;
|
|
7
|
+
private currentLayoutType;
|
|
8
|
+
private isCytoscapeEnabled;
|
|
9
|
+
private currentLayout;
|
|
10
|
+
constructor(config: any);
|
|
11
|
+
setOptions(options: any): void;
|
|
12
|
+
private getLayout;
|
|
13
|
+
private setLayout;
|
|
14
|
+
copyLayoutPositions(nodeList: any, prevLayout: any, nextLayout: any): void;
|
|
15
|
+
update(refreshPositions?: boolean): void;
|
|
16
|
+
getShouldUpdate(): boolean;
|
|
17
|
+
getComputing(): boolean;
|
|
18
|
+
updateNodes(positionList: any): void;
|
|
19
|
+
getNodePositions(data: any): any[];
|
|
20
|
+
terminateUpdate(): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NvlState } from '../../../modules/state';
|
|
2
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
|
+
import AnimatedLayout from '../../animatedlayout/AnimatedLayout';
|
|
4
|
+
type LayoutData = {
|
|
5
|
+
elements: {
|
|
6
|
+
group: string;
|
|
7
|
+
data: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
}[];
|
|
11
|
+
spacingFactor: number;
|
|
12
|
+
};
|
|
13
|
+
export declare class CoseBilkentLayout extends AnimatedLayout {
|
|
14
|
+
private stateDisposers;
|
|
15
|
+
cytoCompleteCallback: () => void;
|
|
16
|
+
computing: boolean;
|
|
17
|
+
pendingLayoutData: LayoutData;
|
|
18
|
+
worker: SharedWorker;
|
|
19
|
+
constructor(config: {
|
|
20
|
+
state: NvlState;
|
|
21
|
+
cytoCompleteCallback?: () => void;
|
|
22
|
+
animationCompleteCallback?: () => void;
|
|
23
|
+
});
|
|
24
|
+
setOptions(options: any): void;
|
|
25
|
+
update(refreshPositions?: boolean, updateMobXNodes?: Node[], updateMobXRelationships?: Relationship[]): void;
|
|
26
|
+
getShouldUpdate(): boolean;
|
|
27
|
+
getComputing(): boolean;
|
|
28
|
+
layout(nodes: Node[], relationships: Relationship[]): void;
|
|
29
|
+
terminateUpdate(): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|